Language change proposal

Chris Pressey cpressey@REDACTED
Wed Oct 22 18:29:25 CEST 2003


On Wed, 22 Oct 2003 13:26:30 +0200 (CEST)
Joe Armstrong <joe@REDACTED> wrote:

> 
> Hi everybody - I'd like to propose the following language change:
> 
> (It's *very* easy to implement)
> 
> I want all Erlang modules to be tagged with a "language version"
> 
> Like this ...
> 
> ---------------------------------------------------------------------
> ---
> 
>     Suppose the next version of Erlang is 5.3 then:
> 
> 	1) All modules *must* start
> 
> 	-module(XXXX).
> 	-vsn("5.3").

It's a good idea, but wouldn't it be easier to write code that works on
different versions if it was done with macros,  e.g.

  -ifdef(?ERLANG_5_3).
  % some code that uses bleeding-edge features here
  -else.
  -ifdef(?ERLANG_5_2).
  % some code that uses 5.2-isms here
  -else.
  % some code that is dangerously language-version-unspecific here
  -endif.
  -endif.

I think this would be the way to go if you wanted to write code that
takes advantage of new features while still being able to compile and
run on older installations.

Even slicker would be if there was a single ?ERLANG_VERSION predefined
macro, and a way to check its value with conditional compilation.

Nothing earthshatteringly new, of course (are we finally catching up to
cpp? :)

-Chris



More information about the erlang-questions mailing list