Porting D2 code to D1
Jason House
jason.james.house at gmail.com
Thu Jul 17 08:50:45 PDT 2008
Jarrett Billingsley Wrote:
> "Jason House" <jason.james.house at gmail.com> wrote in message
> news:g5nhb4$r9d$1 at digitalmars.com...
> > Jarrett Billingsley Wrote:
> >
> >> "Jason House" <jason.james.house at gmail.com> wrote in message
> >> news:g5lib0$23ju$1 at digitalmars.com...
> >>
> >> > I can't imagine any library maintainer being willing to do that just
> >> > for
> >> > portability between D versions. It'd be nice if D2 code could have
> >> > something like version(d1){} and version(d2){} for this purpose.
> >> > That'd
> >> > then allow the d2 compiler to ignore version(d1){} and allow the
> >> > converter
> >> > to strip out version(d2){}
> >>
> >> I've always been dubious about using the version construct for various
> >> language versions. It's great for program options, but since the stuff
> >> in
> >> the version block has to be syntactically legal, it makes it worthless
> >> for
> >> supporting multiple versions of D.
> >
> >
> > Who says what's in version(d1) has to be legal D1 code? ;) I'd vote that
> > the code would still look like D2 code and would be converted in the same
> > way as all other code.
>
> Oh, oh, I see what you're saying now. Those version blocks would just be
> dealt with by the converter, not the compiler.
>
>
Done right, the code could compile as D2 code out of the box. Using my ad hoc example, that'd require version=d2 to be included in the source. The version(d1) would silently (and correctly) be ignored. I don't know if this is best, but it certainly seems simple enough to do
More information about the Digitalmars-d
mailing list