|
Archives
D Programming
DD.gnu digitalmars.D digitalmars.D.bugs digitalmars.D.dtl digitalmars.D.dwt digitalmars.D.announce digitalmars.D.learn digitalmars.D.debugger C/C++ Programming
c++c++.announce c++.atl c++.beta c++.chat c++.command-line c++.dos c++.dos.16-bits c++.dos.32-bits c++.idde c++.mfc c++.rtl c++.stl c++.stl.hp c++.stl.port c++.stl.sgi c++.stlsoft c++.windows c++.windows.16-bits c++.windows.32-bits c++.wxwindows digitalmars.empire digitalmars.DMDScript |
D - Conditional compilation
I posted some new specs on conditional compilation at:
www.digitalmars.com/d/attribute.html
Dec 02 2001
Looks better. I think you should allow debug and version attributes to
contain not only declarations, but also statements, if at a scope where
statements are allowed. I don't want to have to make a whole 'nother copy
of a function just to be able to change one statement inside for a
particular version.
Also I think someone could get into lots of trouble using the version (
whatever ) : form of the AttributeElse, especially at module scope. Is
there a way to go back to the "normal" version, such as version : ?
I'd much rather require use of { } instead of allowing one to use : to
specify an attribute for anything which follows. Too easy to forget to
close those off.
Sean
"Walter" <walter digitalmars.com> wrote in message
news:9uctpi$2rvp$1 digitaldaemon.com...
Dec 02 2001
"Sean L. Palmer" <spalmer iname.com> wrote in message news:9ud0fr$2upb$1 digitaldaemon.com...Looks better. I think you should allow debug and version attributes to contain not only declarations, but also statements, if at a scope where statements are allowed. I don't want to have to make a whole 'nother copy of a function just to be able to change one statement inside for a particular version. Dec 02 2001
Ahhh.. I see what you're doing. Are there any other places where a version
would be nice to have? I can think of a few:
Formal parameter list
Array initializer list
If it's to replace macro-style conditional compilation, you should be able
to use version or debug just about anywhere it can possibly be parsed
properly. I'd *really* like to be able to version a function signature
without having to duplicate the entire function body.
On a semi-related note, can we define our own attributes? For instance if I
wanted to switch a whole lot of functions from one calling convention to
another, I'd like to do this:
version (cdecl_sig)
{
attribute mycall = cdecl;
}
version (stdcall_sig)
{
attribute mycall = stdcall;
}
attribute mycall void myfunc(int a)
{
}
attribute mycall void myfunc2(int a)
{
}
attribute mycall void myfunc3(int a)
{
}
Rather than have to version each function separately, with its associated
duplication of function bodies.
Sean
"Walter" <walter digitalmars.com> wrote in message
news:9udncu$lfn$1 digitaldaemon.com...
Dec 02 2001
"Sean L. Palmer" <spalmer iname.com> wrote in message news:9ue60n$13ps$1 digitaldaemon.com...Ahhh.. I see what you're doing. Are there any other places where a Dec 02 2001
Walter wrote:"Sean L. Palmer" <spalmer iname.com> wrote in message news:9ue60n$13ps$1 digitaldaemon.com...On a semi-related note, can we define our own attributes? For instance if I wanted to switch a whole lot of functions from one calling convention to another, I'd like to do this [...snip...] Dec 02 2001
Yeah, and that brings up a point. Is this legal D?
version (verstdcall)
{
attribute (stdcall) :
}
version (vercdecl)
{
attribute (cdecl) :
}
void Foo(int) {}
I guess it is since version attributes don't introduce a new scope. I doubt
that this form would work however:
version (verstdcall)
{
attribute (stdcall) {
}
version (vercdecl)
{
attribute (cdecl) {
}
void Foo(int) {}
}
Looks like parsing problems to me, no matter if you put the '{' inside the
version or outside it.
I guess my main point here is that people are going to want to version the
darndest things, so it should be supported at as many points in parsing as
possible without jeopardizing the rest of the language design.
Sean
"Russell Borogove" <kaleja estarcion.com> wrote in message
news:3C0ABBFD.93A1A76B estarcion.com...
Dec 03 2001
"Sean L. Palmer" <spalmer iname.com> wrote in message news:9ufhcq$2ja5$1 digitaldaemon.com... Dec 03 2001
"Walter" <walter digitalmars.com> wrote in message news:9ue9ed$17jq$1 digitaldaemon.com..."Sean L. Palmer" <spalmer iname.com> wrote in message news:9ue60n$13ps$1 digitaldaemon.com...Formal parameter list Dec 03 2001
"Sean L. Palmer" <spalmer iname.com> wrote in message news:9ufh3g$2j2s$1 digitaldaemon.com..."Walter" <walter digitalmars.com> wrote in message news:9ue9ed$17jq$1 digitaldaemon.com..."Sean L. Palmer" <spalmer iname.com> wrote in message news:9ue60n$13ps$1 digitaldaemon.com...Formal parameter list Dec 03 2001
|