[erlang-questions] reserved word guaranteed to be atom if single-quoted?

Richard O'Keefe ok@REDACTED
Mon Feb 22 00:37:05 CET 2010


On Feb 20, 2010, at 9:50 PM, Michael Turner wrote:
> And I've been tinkering with a style of argument passing where one  
> might
> write
>
>  the_frob ({of, This_thing}, {within, That_other_thing}, ....)
>
> as a kind of poor man's syntactic sugar for the folks I'm writing my
> code for (who aren't programmers, much less Erlang programmers, just
> algorithm-specifiers).

(1) I have previously written about adapting Paul Lyons' "split  
procedure
     names" to Erlang, where this would appear as
	the frob of(This_Thing) within(That_Other_Thing)

>  Of course, the Erlang parser complains about my
> "of".

(2) New keywords have been added to Erlang over time.
     There is no reason to believe that we have the final set yet.
     It would be nice if Erlang code could be "future-proofed".
     One approach (which I've tried in a tokeniser, and seems to
     work tolerably well) is that
  -  an identifier *immediately* followed by '(' is always a
     plain function name
  -  an identifier preceded by one of
	( [ { , | ; -> =
     and followed by one of
	) ] } , | ; -> =  end
     is always a plain atom even if it would otherwise be a keyword.

(3) As things stand, it's not just Erlang *source code* that can be
     invalidated by additions to the language.  It's Erlang *data*
     that might be saved in text files or sent a machine running
     version X to another running version Y where Y > X.  With this
     revision to the "when is it a keyword" rule, there would never
     be any need to quote identifier-like atoms, no invalidation of
     old data, and no need to change the output code.



More information about the erlang-questions mailing list