Wiki

Changes between Version 1 and Version 2 of IfDirective

Show
Ignore:
Timestamp:
01/10/13 02:08:36 (12 years ago)
Author:
Charles
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • IfDirective

    v1 v2  
    33This does not describe an existing feature. It's place to jot down notes for my idea of an @if directive and related features. 
    44 
    5 == Introduction == 
     5== Motivation == 
    66 
    7 Conditional inclusion of source code is needed in some circumstances. Some of the better known ones are: 
     7Conditional inclusion of source code (aka "conditional compilation") is needed in some circumstances. Some of the better known ones are: 
    88 * Adjusting for the back-end (CLR, JVM) 
    99 * Demo vs. Production 
     
    1111 * Adjusting for compiler options (-include-tests, etc.) 
    1212 
     13Other 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 
     17General, full form: 
     18{{{ 
     19#!cobra 
     20@if <condition> 
     21   <code> 
     22@else if <condition> 
     23   <code> 
     24@else 
     25   <code> 
     26}}} 
     27But "@else if" and "@else" are optional and "@else if" can be repeated. 
     28 
     29== Defining Symbols == 
     30 
     31{{{ 
     32cobra -define:FOO -define:FOO=bar ... 
     33}}} 
     34 
     35Or in code: 
     36{{{ 
     37#!cobra 
     38@define FOO 
     39@define FOO = 'bar' 
     40}}} 
     41 
     42== Automatic Symbols == 
     43 
     44CLR, 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 
     48clr, jvm, objc, dotnet, etc. 
     49 
     50 
    1351== See Also == 
    1452 
     53 * Discussion at http://cobra-language.com/forums/viewtopic.php?f=4&t=966 
    1554 * CompilerDirectives 
    1655 * LanguageTopics