Smooth transition to D2 for Tango users?
Bruce Adams
tortoise_74 at yeah.who.co.uk
Sat Sep 20 03:04:08 PDT 2008
On Thu, 18 Sep 2008 03:43:22 +0100, Jason House
<jason.james.house at gmail.com> wrote:
> Denis Koroskin Wrote:
>
>> On Wed, 17 Sep 2008 18:31:02 +0400, Jason House
>> <jason.james.house at gmail.com> wrote:
>>
>> > I'd like to see a smooth transition for Tango, not just the users! I
>> > made several posts on the topic. The latest was titled "forward
>> > compatibility" -- Making the D1 compiler tolerant of code that looks
>> > like D2, but not adding new functionality...
>> >
>>
>> Please, Walter, comment on this!
>> Shall we put the request into bugzilla?
>
> My last bugzilla request still doesn't have a response... Walter has
> said before that he doesn't like raining on people's parade, so maybe
> his silence should be assumed to be a rejection?
The thing is what you are asking for is a major change to the D1.0 spec.
D1.0 is frozen. Bug fixes (to the spec) are permitted but major additions
are not. Moreoever this addition does not add any functionality. So while
it
may seem like a sensible thing to do from a pragmatic programmer's point
of view
from a language design point of view its very silly indeed.
You need to find a difficult way to tackle the problem.
Its not a simple as the vanilla case of wanting one code base to support
two
dialects of the same language (e.g. two difficult non standard C++
compilers before
we had a standard). As I understand it its the const system in D2.0 makes
it more
complicated. People have posted clever suggestions using templates but
these make
both the D1 and D2 code ugly.
How about using source code transformation instead. Generate D1.0
compliant code from
D2.0 code (with a minimum number of version blocks for the ugly stuff).
Kind of a
DFront if you like. It needs specing in more detail but here are some
ideas to ponder:
* strip const's and invariants from the source in appropriate contexts
- const is legal/sensible in some places in D1.0 which is why sed -e
s/const//g won't be enough
- ideally use a D1.0 parser (you can only do simple source code
transformations without it - maybe that would be enough)
* use source code annotations specific to your Doneificator program (for
the bits a brain dead translator can't handle alone)
- @deletemethod - remove the method entirely from the translation
- @noconst - remove const from the following line / block of code
- @keepconst - do not remove const from the following line / block of
code
Have a configure script which checks which versions of the compiler you
have available.
For library developers the build system would build both variants in
different sub-directories
source/
foo.d (annotated D2.0)
v1/
foo.d - D1.0 variant
V2/
foo.d - D2.0 variant
Put the clever stuff into your makefile:
V1/foo.d: foo.d
dtrans --toD1 $< $@
V2/foo.d: foo.d
dtrans --toD2 $< $@
or
DIALECT=--toD1
foo.o: foo.d
dtrans $(DIALECT) $< $@
dmd $(DFLAGS) ...
You have have your configure script set your DIALECT appropriately to your
environment and ensure your
DFLAGS includes the right version setting for the bits 'dtrans' can't
handle.
Having to do this sort of is why having a build system means more than
just having an IDE with a half arsed notion of projects
(I'm talking to you windows VC++ :)
If you do need to write such a beast it would probably fit well with one
of the build tools like DSSS
but it should be standalone so everyone that care's can benefit.
Regards,
Bruce.
More information about the Digitalmars-d
mailing list