syntactic sugar

Ulf Wiger etxuwig@REDACTED
Mon Feb 10 14:42:02 CET 2003

I've often thought that it would be nice to be able to have
a more convenient way of matching tagged tuples. Example:

  when element(1,Msg) == leader ->
  when element(1,Msg) == leader ->

I'd like to be able to write:

handle_cast({leader|_} = Msg, {surrendered,Data}) ->
handle_cast({leader|_} = Msg, {elected,Data}) ->

There are of course workarounds:

- I could use records, but the idea of specifying a
  'message' record doesn't appeal to me, and I think
  it would actually result in _more_ typing.

- I could use lists instead of tuples. Well, why not,
  except it doesn't follow the convention.

I boldly hacked the erl_parse.yrl grammar file to introduce
the syntax change, thinking I could handle it in a
parse_transform, but the linter choked on the new
representation before my parse transform was called. This
made me drop the project (you can only spend so much time
goofing around with silly ideas...)

Why does the linter run before the parse transform?

Ulf Wiger, Senior Specialist,
   / / /   Architecture & Design of Carrier-Class Software
  / / /    Strategic Product & System Management
 / / /     Ericsson AB, Connectivity and Control Nodes

More information about the erlang-questions mailing list