D - Conditional compilation
- Walter (2/2) Dec 02 2001 I posted some new specs on conditional compilation at:
- Sean L. Palmer (14/16) Dec 02 2001 Looks better. I think you should allow debug and version attributes to
- Walter (6/17) Dec 02 2001 The version statement is the analogous syntax to enclose statements. The...
- Sean L. Palmer (36/53) Dec 02 2001 Ahhh.. I see what you're doing. Are there any other places where a vers...
- Walter (12/42) Dec 02 2001 version
- Russell Borogove (4/19) Dec 02 2001 Unless you need to switch the calling convention for several modules at
- Sean L. Palmer (32/51) Dec 03 2001 Yeah, and that brings up a point. Is this legal D?
- Walter (8/33) Dec 03 2001 Yes. Thanks for that, I hadn't realized that worked!
- Sean L. Palmer (10/20) Dec 03 2001 I don't think that'd cover it completely. I'm thinking more of replacin...
- Walter (6/20) Dec 03 2001 a
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...I posted some new specs on conditional compilation at: www.digitalmars.com/d/attribute.html
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.The version statement is the analogous syntax to enclose statements. There are no version expressions, however <g>.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 :tospecify an attribute for anything which follows. Too easy to forget to close those off.That's done to be consistent with all the other attributes.
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..."Sean L. Palmer" <spalmer iname.com> wrote in message news:9ud0fr$2upb$1 digitaldaemon.com...copyLooks 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(of a function just to be able to change one statement inside for a particular version.The version statement is the analogous syntax to enclose statements. There are no version expressions, however <g>.Also I think someone could get into lots of trouble using the versionIswhatever ) : form of the AttributeElse, especially at module scope.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 :tospecify an attribute for anything which follows. Too easy to forget to close those off.That's done to be consistent with all the other attributes.
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 aversionwould be nice to have? I can think of a few: Formal parameter listI think this can be avoided by overloading with a version'd function.Array initializer listYou have me there.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 ifIwanted 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.I see what it is you want, how about this: attribute (whatever) { all those functions } Then it's only one place to change the attribute.
Dec 02 2001
Walter wrote:"Sean L. Palmer" <spalmer iname.com> wrote in message news:9ue60n$13ps$1 digitaldaemon.com...Unless you need to switch the calling convention for several modules at once. -RBOn 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...]I see what it is you want, how about this: attribute (whatever) { all those functions } Then it's only one place to change the attribute.
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...Walter wrote:instance if"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? Forconvention toI wanted to switch a whole lot of functions from one callingUnless you need to switch the calling convention for several modules at once. -RBanother, I'd like to do this [...snip...]I see what it is you want, how about this: attribute (whatever) { all those functions } Then it's only one place to change the attribute.
Dec 03 2001
"Sean L. Palmer" <spalmer iname.com> wrote in message news:9ufhcq$2ja5$1 digitaldaemon.com...Yeah, and that brings up a point. Is this legal D? version (verstdcall) { attribute (stdcall) : } version (vercdecl) { attribute (cdecl) : } void Foo(int) {}Yes. Thanks for that, I hadn't realized that worked!I guess it is since version attributes don't introduce a new scope. Idoubtthat this form would work however: version (verstdcall) { attribute (stdcall) { } version (vercdecl) { attribute (cdecl) { } void Foo(int) {} }No, that won't work. It's important to remember that version(){} is part of the syntax, it is not a separate language interleaved into D.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.While it's true one can write FORTRAN in any language <g>, to make D small and easy to comprehend, each feature needs a compelling reason for it.
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...I don't think that'd cover it completely. I'm thinking more of replacing a function signature entirely, not merely adding an overload. And not duplicating function body code.Formal parameter listI think this can be avoided by overloading with a version'd function.I see what it is you want, how about this: attribute (whatever) { all those functions } Then it's only one place to change the attribute.Yes I suppose that'll do. Could even use "attribute :" ;) Just so long as no module-scope variables were in there anywhere. What'll happen if you apply an illegal attribute to something, such as a calling convention to a variable? Sean
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...a"Sean L. Palmer" <spalmer iname.com> wrote in message news:9ue60n$13ps$1 digitaldaemon.com...I don't think that'd cover it completely. I'm thinking more of replacingFormal parameter listI think this can be avoided by overloading with a version'd function.function signature entirely, not merely adding an overload. And not duplicating function body code.Use two inline wrapper functions and a third implementation function.What'll happen if you apply an illegal attribute to something, such as a calling convention to a variable?Nothing. If it's a global variable, you'll get the appropriate name mangling.
Dec 03 2001