[erlang-questions] some language changes

andrew cooke andrew@REDACTED
Mon May 21 16:36:19 CEST 2007


> Now the book is done I've been thinking about some language changes.
>
> Here's my list (no particular priority)
>
> 1. What you type in the shell and what you type in a module/escript
> should be the same
>
> 2. Hashmaps (aka associative arrays)
>
> 3. Extended string syntax: idea - put an atom *before the string quote
>     to say what the string means and to *change* the syntax rules that
> apply
>     to the string content.
>
>      X = C "......"
>           C = a control atom
>
>        X = regexp " ... "
>
>           = html " .... "
>
>          Then we could write regexps and LaTeX inside strings without
>          all the horrible additional quotes
>
> 4. Simple string substitutions
>
>      X = subst "aaa ${P} bbb ${Q} ccc"
>
>       *means*    X = [<"aaa">, P, <"bbb">, Q, ...]

It's a pity that the syntax can't be related to that used in io:format
somehow.  Also, as well as implicitly using names in the current scope, it
might be nice if an explicit map from names to values could be specified.

One use case from my own experience that might help here is generating SQL
statements from templates.  That required that
- the template should be a separate entity, that can be re-used with
different sets of values (so parsing of the template only occurs once)
- there be some way of customizing the conversion from value to string of
characters (without an explicit type system that probably means additional
names in the template that specify conversion functions).

This is probably getting more complex than you intended - perhaps it's
only helpful in suggesting some caution before adding syntax that address
only a limited use case.

Andrew


>
>      This would be very useful.
>
> None of these are large changes - but they would make Erlang a nicer
> language
> to program in. The (regexp "....") would be extremely useful to the
> compiler
> and allow generating efficient regexp matching code :-)
>
> Comments?
>
> /Joe
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
>
>





More information about the erlang-questions mailing list