[erlang-questions] New draft of frames proposal (was Re: Frames proposal)

Hynek Vychodil <>
Thu May 3 15:14:13 CEST 2012


If I understand ROK right, the main problem which worries him is code like this

{
  quix
    % some comment or some more code
  , <{ a:1
    % some comment or some more code
    , foo:bar(Ugh)
    , baz:quux(Eh)
    % some comment or some more code
  }>
    % some comment or some more code
  , [ ...]
    % some comment or some more code
}

When you see code snippet/line with foo:bar(Ugh) you have to very
carefully scan surrounding code when you are willing to know what the
hell is going on and above example is relatively pretty formatted and
indented. It can be far worse in real world application and with
little bit more levels as

{ok, <{ foo:{bar, baz, <{foo:bar(Ugh), baz:quux(Eh)}>, foo:bar(Och)}, a:2 }>}

Good luck with this syntax.

On Thu, May 3, 2012 at 1:02 PM, Tim McNamara
<> wrote:
> On 3 May 2012 22:50, José Valim <> wrote:
>>> I don't understand this example [p16]
>>>
>>>    foo:bar(Ugh),
>>>
>>> How is this ambiguous? Are you trying to set the bar element from the
>>> foo frame? Your next line is unclear.
>>
>>
>> It is ambiguous because:
>>
>>     { foo:bar(Ugh) }
>>
>> Could be a tuple with one element which is the result of foo:bar(Ugh) or
>> a frame with key foo and value bar(Ugh) (according to your proposal).
>> There is also the "ambiguity" in {}. Is it an empty frame or an empty tuple?
>
> Ah, understood. There is certainly an opportunity for error here.
> Could {:} represent the empty frame?
>
>>
>> <{ foo: bar(Ugh) }> could work because there would be no ambiguity for
>> the compiler, but it would be still ambiguous for humans (damn you, humans).
>> I would shrug if I read a code like <{ foo:bar(Ugh) }> that actually means
>> <{ foo: bar(Ugh) }>.
>
> FWIW, I think this is probably acceptable. If <{ }> was accepted, it
> implies an intent on the programmer's behalf that they wanted to
> create a frame, which requires a key and a value.
> _______________________________________________
> erlang-questions mailing list
> 
> http://erlang.org/mailman/listinfo/erlang-questions



-- 
Hynek Vychodil
BI consultant

GoodData
náměstí 28. října 1104/17, 602 00, Brno - Černá Pole
Office:   +420 530 50 7704
E-mail:  
Web:     www.gooddata.com



More information about the erlang-questions mailing list