Re: New keywords: ifdef, elsifdef, end ifdef
Jeremy Cowgar wrote:
> }}}
<eucode>
> ifdef debug then
> puts(1, "Debug version\n")
> else
> puts(1, "Release version\n")
> end ifdef
> </eucode>
{{{
>
> No need for a elseifdef. We would want to introduce less keywords to make it
> easier for the programmer and faster in the parsing.
Congratulations on implementing this feature!
This is a feature that I wished very much.
However, I don't really like the syntax.
Especially the elsifdef, it looks like a cramped abbreviation.
Other suggestions that came in mind:
1. Use another keyword after "if" like "defined"
if defined LINUX then
-- linux code
elsif defined WIN32 then
-- win32 code
else
-- whatever
end if
Adv: only 1 new keyword instead of 2. Less abbreviation.
Dis: harder to implement (?)
2. Use static if (idea from D)
static if VERSION > 400 then
puts(1, "you are in the future!")
elsif VERSION < 400 then
puts(1, "Please upgrade")
else
puts(1, "hohoho");
end if
Adv: One keyword instead of 2. Only need to write "static" once instead of 2
times "defined" like above. Can use >, <, = instead of just boolean testing.
Dis: same as above
3. Use $ for "preprocessor" variables (variables that are defined during
compilation), no need to use new keywords.
if $VERSION > 400 then
puts(1, "you are in the future!")
elsif $DOS32 then
puts(1, "good old-timer")
else
puts(1, "hohoho");
end if
Adv: The $ sign makes it stands out from normal if-statement. $ sign is already
used so no new keyword or symbol introduced. Can use >, <, = instead of just
boolean testing.
Dis: none?
____
Personally I prefer the 3rd point above.
How do you think?
|
Not Categorized, Please Help
|
|