What library functionality would you most like to see in D?
Jonathan M Davis
jmdavisProg at gmx.com
Sun Jul 31 19:38:11 PDT 2011
On Sunday 31 July 2011 22:28:51 Johann MacDonagh wrote:
> On 7/31/2011 9:56 PM, Jonathan M Davis wrote:
> > If we do a hand-written lexer of D for Phobos, it really should be a
> > fairly direct port of the dmd front-end. It should be _somewhat_
> > D-ified as appropriate, (and the API should definitely be properly
> > range-based and all that), but the implementation needs to be fairly
> > close to dmd itself so that it's easy for someone to port changes and
> > fixes back and forth between the two. Otherwise, they're going to get
> > out of sync fairly easily. If we're not going to do a direct port, then
> > we might as well just do the template-based lexer generator that Andrei
> > and others would really like to see (which we should still do, but I
> > think that the hand-written lexer is nowhere near as valuable if it's
> > not a direct port of dmd's lexer).
>
> Yeah, I get the point, but I feel that I could port most trivial changes
> from DMD's lexer to lexer.d. The layout of the code is different, of
> course, but I'm borrowing most of the lexing logic from DMD. Plus with
> unittests, I think we could ensure things are lexing the same.
>
> > Also, I see _zero_ value in making it support D1. If it's for D2's
> > standard library, then what's the point of it lexing D1? That just
> > complicates the lexer for what is essentially a legacy product. And
> > given that the differences between D1 and D2 in dmd's lexer are covered
> > with #ifdefs, it would be rather complicated to try and do a direct
> > port which covers both D1 and D2. It would probably be easier if the
> > two were completely separate.
>
> Well, it doesn't appear that there are that many lexical differences
> between D1 and D2. A few operators, a few keywords, D2 supports a few
> different string constants, etc...
>
> I wanted this to be usable by IDEs. Do we not want to support D2 for
> development? I could certainly make this D2 only.
Phobos for D2 is for D2, not D1. Mixing D1 into the mix complicates things. If
it's easy to tell the lexer to lex D1 or D2 without negatively impacting
performance and without seriously impacting the implementation, then we can
support D1. But personally, I don't think that it's worth the extra
complication. The compiler separates them with ifdefs, which isn't going to
work as well in Phobos. You'd probably end up having to use templates and
static ifs to deal with the differences. It can be done, but I don't think that
it's worth the gain. The lexer is complicated enough as it is.
- Jonathan M Davis
More information about the Digitalmars-d
mailing list