new syntax - a provocation

Vlad Dumitrescu vlad_dumitrescu@REDACTED
Mon Sep 22 21:27:11 CEST 2003


Since new syntax constructs have been discussed, I have some ideas that I'd
like to present here. The intention is to spur some more ideas, and maybe
some will find a growing ground.

* I have found myself wishing to be able to build data structures other than
tuples or lists, in the same elegant way as tuples and lists, directly in
the code. The most acute need was for bitsets/integer sets, where using the
binary syntax is very cumbersome when there are many such sets to be
declared. It would be super-nice to be able to write something like
    &[3, 45, 27, 39],
where the first is a bit representation, and the latter a set containing the
specified integers. The implementation would be as binaries, so just the
syntax is new.

* I thought this could be solved with a parse transform, but I think the
lexer should be able to cope with new tokens too, since overloading existing
ones would only make a mess out of it. That's why I thought "why not
introduce something similar to Lisp's reader macros?" We could have a
special char (for example, @) to use in constructs like
that will be transformed into something like (in this case)
and evaluated at compile time into "real" Erlang.

* Having come this far, and remembering Tobbe's (I think) call for Erlang2,
and also Luke's Lisp parallels, there is one more small step to take, for
those that like to play on the edge: Why not replace the whole Erlang syntax
to a more Lispy one? (or more correctly, closer to CoreErlang) A
different-looking language, but the same BEAM code and runtime. There are
many aspects of such a syntax that add plenty of power to Lisp, why not use
that power?

Note: I am too aware of some of the (many) downsides. I tried to be a little
provocative by leaving them out, and also any examples and possible


More information about the erlang-questions mailing list