Thread overview | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
September 02, 2007 What is the point of D_Version2 | ||||
---|---|---|---|---|
| ||||
Okay, I just don't get it.
This code below doesn't compile in V1 dmd.
version(D_Version2)
{
alias const(wchar)[] wstring;
alias const(dchar)[] dstring;
}
else
{
alias char[] string;
alias wchar[] wstring;
alias dchar[] dstring;
}
I can understand why - because the first two alias declarations have invalid V1 syntax - but doesn't that make the whole D_Version2 thing pointless?
--
Derek Parnell
Melbourne, Australia
skype: derek.j.parnell
|
September 02, 2007 Re: What is the point of D_Version2 | ||||
---|---|---|---|---|
| ||||
Posted in reply to Derek Parnell | On Sun, 2 Sep 2007 22:50:32 +1000, Derek Parnell wrote:
P.S. I finally got Bud to compile using V2 after about a thousand tiny changes and now I want to tweak so I can also compile the same source in V1.
Needless to say, but there will be a slight delay in the next Bud release until I sort out this next bloody irritation.
--
Derek Parnell
Melbourne, Australia
skype: derek.j.parnell
|
September 02, 2007 Re: What is the point of D_Version2 | ||||
---|---|---|---|---|
| ||||
Posted in reply to Derek Parnell | Derek Parnell wrote:
> On Sun, 2 Sep 2007 22:50:32 +1000, Derek Parnell wrote:
>
> P.S. I finally got Bud to compile using V2 after about a thousand tiny
> changes and now I want to tweak so I can also compile the same source in
> V1.
>
> Needless to say, but there will be a slight delay in the next Bud release
> until I sort out this next bloody irritation.
>
Can you work around it by separating the aliases out into separate v1 and v2 d-files? Like
version(D_Version2)
{
import v2types;
}
else
{
import v1types;
}
--bb
|
September 02, 2007 Re: What is the point of D_Version2 | ||||
---|---|---|---|---|
| ||||
Posted in reply to Derek Parnell | Dnia Sun, 2 Sep 2007 22:50:32 +1000 Derek Parnell <derek@psych.ward> napisaĆ/a: > Okay, I just don't get it. > > This code below doesn't compile in V1 dmd. > > version(D_Version2) > { > alias const(wchar)[] wstring; > alias const(dchar)[] dstring; > } > else > { > alias char[] string; > alias wchar[] wstring; > alias dchar[] dstring; > } > > > I can understand why - because the first two alias declarations have invalid V1 syntax - but doesn't that make the whole D_Version2 thing pointless? Unfortunetly this is correct behavior. Even when D_Version2 is undefined, anything which is inside must be syntacticly correct. const(wchar) is incorrect for D1. :/ -- Witold Baryluk, aleph0 MAIL: baryluk@smp.if.uj.edu.pl JID: movax@jabber.autocom.pl |
September 02, 2007 Re: What is the point of D_Version2 | ||||
---|---|---|---|---|
| ||||
Posted in reply to Derek Parnell | Derek Parnell wrote:
> This code below doesn't compile in V1 dmd.
> [...]
> I can understand why - because the first two alias declarations have
> invalid V1 syntax - but doesn't that make the whole D_Version2 thing
> pointless?
Um, I see it's a pain. Surely you know the string mixin workaround?
Regards, Frank
|
September 02, 2007 Re: What is the point of D_Version2 | ||||
---|---|---|---|---|
| ||||
Posted in reply to 0ffh | 0ffh wrote:
> Um, I see it's a pain. Surely you know the string mixin workaround?
Someone posted it somewhere at some time.
I currently use this for strings:
---<snip>---
version (D_Version2)
{
mixin("alias invariant(char)* icptr;");
alias char* cptr;
}
else
{
alias char* icptr;
alias char* cptr;
alias char[] string;
}
---<snap>---
Or were you just complaining about the lack of elegance here?
Regards, Frank
|
September 02, 2007 Re: What is the point of D_Version2 | ||||
---|---|---|---|---|
| ||||
Posted in reply to 0ffh | 0ffh wrote: > Derek Parnell wrote: > >> This code below doesn't compile in V1 dmd. >> [...] >> I can understand why - because the first two alias declarations have >> invalid V1 syntax - but doesn't that make the whole D_Version2 thing >> pointless? > > > Um, I see it's a pain. Surely you know the string mixin workaround? > > Regards, Frank > > For the record, the string mixin workaround looks like this: version (D_Version2) { mixin("alias const(char)* c_str;"); } else { alias char* c_str; } You can find this code near the top of the Python header. http://dsource.org/projects/pyd/browser/trunk/infrastructure/python/python.d So far as I can tell, I was the first person to come up with (or at least use) this workaround, but others may have come up with it on their own. -- Kirk McDonald http://kirkmcdonald.blogspot.com Pyd: Connecting D and Python http://pyd.dsource.org |
September 02, 2007 Re: What is the point of D_Version2 | ||||
---|---|---|---|---|
| ||||
Posted in reply to Derek Parnell | Derek Parnell wrote: > Okay, I just don't get it. > > This code below doesn't compile in V1 dmd. > > version(D_Version2) > { > alias const(wchar)[] wstring; > alias const(dchar)[] dstring; > } > else > { > alias char[] string; > alias wchar[] wstring; > alias dchar[] dstring; > } > > > I can understand why - because the first two alias declarations have > invalid V1 syntax - but doesn't that make the whole D_Version2 thing > pointless? > Have you read this thread? Thomas Kuehne explains how to write code that works in both D 1 and 2. http://www.digitalmars.com/d/archives/digitalmars/D/supporting_DMD-1.016_and_DMD-2.000_with_the_same_source_code_54628.html |
Copyright © 1999-2021 by the D Language Foundation