Re: [fpc-devel] RFC: changing conditional compilation
Hi Jonas, As you can imagine I'd prefer to solve the $ifdef problem ;-) To be honest: no, I can't imagine why you would prefer that. The entire difference between $ifdef and $if is that $if checks the value of something (and hence will give an error if the symbol is undefined) and $ifdef checks whether it is defined or not. As far as I can tell, you would simply like to be able to use boolean constants in $if expressions. Hope you rethink your opinion the next time you forget to add an {$I} or mess up a define name ;-) Best regards, Flávio ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
Re: [fpc-devel] RFC: changing conditional compilation
On 09 Feb 2010, at 01:24, Flávio Etrusco wrote: As far as I know, that's how macros behave. E.g.: {$macro on} {$define xxx:=1} {$if xxx} begin end. {$endif} If you undefine xxx, you'll get a compile time error. Downside: they don't work with booleans for some reason, only with integers... Hi Jonas, As you can imagine I'd prefer to solve the $ifdef problem ;-) To be honest: no, I can't imagine why you would prefer that. The entire difference between $ifdef and $if is that $if checks the value of something (and hence will give an error if the symbol is undefined) and $ifdef checks whether it is defined or not. As far as I can tell, you would simply like to be able to use boolean constants in $if expressions. Yes, I noticed the problem with bools - and that it would fail with string found but boolean expected if the name was undefined -, The latter is the behaviour you want, no? Jonas PS: please reply to the list___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
Re: [fpc-devel] RFC: changing conditional compilation
2010/2/9 Jonas Maebe jonas.ma...@elis.ugent.be: On 09 Feb 2010, at 01:24, Flávio Etrusco wrote: As far as I know, that's how macros behave. E.g.: {$macro on} {$define xxx:=1} {$if xxx} begin end. {$endif} If you undefine xxx, you'll get a compile time error. Downside: they don't work with booleans for some reason, only with integers... Hi Jonas, As you can imagine I'd prefer to solve the $ifdef problem ;-) To be honest: no, I can't imagine why you would prefer that. Because everybody automatically uses $ifdef and most of the code would work with minor intervention. E.g. we usually use something like {.$define EnableDocking} to undefine the symbol. You'd just have to force it explicitly $undef or some kind of {$define EnableDocking disable} or 'false', or something. The entire difference between $ifdef and $if is that $if checks the value of something (and hence will give an error if the symbol is undefined) and $ifdef checks whether it is defined or not. As far as I can tell, you would simply like to be able to use boolean constants in $if expressions. This would solve the problem for my code, not conditionals I'm trying to use on 3rd party code... Yes, I noticed the problem with bools - and that it would fail with string found but boolean expected if the name was undefined -, The latter is the behaviour you want, no? Yes - apart from puzzling error message to the casual users - but it'd require to set a convention on the Macro value for on/off and back to possibly causing errors due to typos. Jonas PS: please reply to the list___ Sorry, I just skip the list sometimes when I think the post will be just noise to other people. I'd certainly get back to it when I have something relevant to say ;-) Best regards, Flávio ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
Re: [fpc-devel] RFC: changing conditional compilation
On 09 Feb 2010, at 00:01, Flávio Etrusco wrote: Now there's Macros, but they wouldn't solve the problem either, unless you'd use some crazy scheme with $if declared or something AFAICS. What I wished is to change (or add a directive to change) the way $ifdef/ifndef work, enforcing that symbols are always declared, like it was a boolean. So one would have to use e.g. {$define EnableFeature false} to undefine it, otherwise conditionals would fail. As far as I know, that's how macros behave. E.g.: {$macro on} {$define xxx:=1} {$if xxx} begin end. {$endif} If you undefine xxx, you'll get a compile time error. Downside: they don't work with booleans for some reason, only with integers... Jonas___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel