[erlang-questions] Here's hoping we get frames or structs in 2009!

Robert Virding rvirding@REDACTED
Mon Jan 12 19:26:18 CET 2009


2009/1/12 Gleb Peregud <gleber.p@REDACTED>

>
> Probably James means that such structure could be used in such a way:
>
> Options0 = #{width=1280, height=1024},
> ...
> Options = Options0#{colors = 256},
> ...
> adjust_screen(Options).
>
> adjust_screen(#{colors = 65536}) -> erlang:error(unsupported);
> adjust_screen(Options = #{width = W, height = H, colors = _}) -> %%
> 'colors = _' would match iff this key is set
>    io:fwrite("selected colors ~b~n", [Options.colors]),  %% or it can
> be Options#colors (confusing) or Options#.colors (awkward...)
>    do_something(...).
>
> I opt for inclusion of such structure into the language. It will
> combine power of dict (dynamic set key-value pairs) and power of
> tuples/records (pattern matching)


I don't think that that will be the case. The suggestions for
implementations given so far all assume relatively small structs/frames,
they would not be replacements for dicts but a replacement, or rather a
complement to, records.


This said I think that they would be a great feature and think they should
be included.

Robert
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20090112/99a6b644/attachment.htm>


More information about the erlang-questions mailing list