[erlang-questions] Re: Special syntax for dictionaries

Richard O'Keefe ok@REDACTED
Thu May 6 04:35:19 CEST 2010


On May 5, 2010, at 7:32 PM, Tim Fletcher wrote:
> Yes, if the values are atoms and you don't put spaces before/after the
> semicolon. Whilst that would be similar to a mod:fun call, there are
> no brackets, so technically there's no ambiguity. Currently that usage
> of the semicolon is illegal syntax, so presumably it could be made to
> work.

What semicolon?  ":" is a colon.

Erlang is not Javascript, so there is no compelling reason why
it should *look* like Javascript.

There are things that are technically unambiguous in a programming
language, but that's very far from being a sufficient criterion
for usability.  For example, in Fortran 66 there were "Hollerith
literals" where you wrote a string as the number of characters
followed by those characters, e.g.,
   15H.NOT.REAL(CODE)
for the string ".NOT.REAL(CODE)".  The *compiler* never had any
trouble with this, but *people* had trouble getting the number
right and far worse trouble reading the result, which is why this
feature isn't in any recent Fortran standard.  (.NOT. is a Fortran
logical negation operator and REAL is a Fortran intrinsic function.)

I'm not sure what brackets [] have to do with it; if you mean
there are no parentheses, there's not the slightest reason why
there should not be:  label ~ func(args) is perfectly possible
and indeed in my experiments with using the notation I have found
a maplet with a function call to be quite common.

You have to consider not just what the *compiler* can process,
but
  - what *people* can rapidly distinguish,
  - what can happen as a result of cut-and-paste editing,
  - what crude approximate parsers like syntax colouring editors
    might have trouble with
  - what's going to happen when people grep for things
  - the fact that spaces are not generally obligatory in Erlang,
    so just saying "you ought to write label: value" is no
    guarantee that it will be done that way



More information about the erlang-questions mailing list