Changes between Version 1 and Version 2 of IfDirective
- Timestamp:
- 01/10/13 02:08:36 (12 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
IfDirective
v1 v2 3 3 This does not describe an existing feature. It's place to jot down notes for my idea of an @if directive and related features. 4 4 5 == Introduction ==5 == Motivation == 6 6 7 Conditional inclusion of source code is needed in some circumstances. Some of the better known ones are:7 Conditional inclusion of source code (aka "conditional compilation") is needed in some circumstances. Some of the better known ones are: 8 8 * Adjusting for the back-end (CLR, JVM) 9 9 * Demo vs. Production … … 11 11 * Adjusting for compiler options (-include-tests, etc.) 12 12 13 Other languages including C# (#if, #define) and D (static if, version, ...) have condition compilation features which are taken advantage of by their communities. 14 15 == Syntax == 16 17 General, full form: 18 {{{ 19 #!cobra 20 @if <condition> 21 <code> 22 @else if <condition> 23 <code> 24 @else 25 <code> 26 }}} 27 But "@else if" and "@else" are optional and "@else if" can be repeated. 28 29 == Defining Symbols == 30 31 {{{ 32 cobra -define:FOO -define:FOO=bar ... 33 }}} 34 35 Or in code: 36 {{{ 37 #!cobra 38 @define FOO 39 @define FOO = 'bar' 40 }}} 41 42 == Automatic Symbols == 43 44 CLR, CLR20, CLR40, JVM, JVM16, JVM17, JVM18, OBJC, DOTNET, MONO, WINDOWS, UNIX, MAC, ASSERTS, TESTS, CONTRACTS, DEBUG, DST, ERT 45 46 ... or we could go all lower case: 47 48 clr, jvm, objc, dotnet, etc. 49 50 13 51 == See Also == 14 52 53 * Discussion at http://cobra-language.com/forums/viewtopic.php?f=4&t=966 15 54 * CompilerDirectives 16 55 * LanguageTopics