Why version() ?

Daniel Keep daniel.keep.lists at gmail.com
Tue Feb 10 19:07:29 PST 2009



Walter Bright wrote:
> Jason House wrote:
>> Would you be willing to introduce an alternative to /+ +/ which would
>> be treated differently by the D1 and D2 compilers? Here are some
>> examples with no attempt at creativity:
>> beginD1 endD1
>> D1 D1 (works like string delimiters)
>> /D2 D2/
> 
> That is an interesting idea. I never thought of that.

What about this?

/+{{VersionIdentifier}} ... +/

The lexer doesn't have to know whether a particular version identifier
is defined or not.  That said, I don't know whether you could keep a
"sort-of comment" around in the AST until the semantic pass; haven't had
much luck deciphering the compiler yet. :P

Plus, it's backwards-compatible! :D

As for what's allowed in the {{..}}, you could always restrict it to a
set of version identifiers that represent syntax-incompatible changes.

  -- Daniel



More information about the Digitalmars-d mailing list