View previous topic :: View next topic |
Author |
Message |
Brent Site Admin
Joined: 01 Jul 2005 Posts: 800
|
Posted: Mar 23rd, 2012, 10:37pm Post subject: Experiment - Compiler directives |
|
|
This is another thought experiment to get feedback on the syntactic possibilities of VF.
Almost all modern languages have a means of controlling how code gets parsed at compile-time. This usually involves defining constants, testing these constants for a particular value (or just their existence), and possibly generating code or aborting a compile.
VF, so far, can parse the following directives:- @define constant - defines a constant
- @if constant - compiles the following code if constant is defined
- @elseif constant - when the preceding @if failed, tests alternative constants
- @else - when all preceding @if and @elseif fail, compile the following
- @endif - ends a conditional
_________________ Brent |
|
Back to top |
|
|
STPendl Full Member
Joined: 20 Aug 2007 Posts: 161 Location: Austria
|
Posted: Mar 24th, 2012, 1:23am Post subject: Re: Experiment - Compiler directives |
|
|
Conditional compilation is very useful, so debugging information can be omitted for the release compilation for instance.
I like that addition. _________________ Stefan
Any code I post can be freely used, just give credit. |
|
Back to top |
|
|
Brent Site Admin
Joined: 01 Jul 2005 Posts: 800
|
Posted: Mar 29th, 2012, 6:14pm Post subject: Re: Experiment - Compiler directives |
|
|
My plan for now is to allow some simple logical operations: And, Or, Not.
Code: | @if Windows
' Windows-specific thing
@if Win64
' Win64-specific thing
@endif
@elseif Linux or MacOS
' *nix-specific thing
@if Linux
' Linux-specific thing
@if not Ubuntu and not Fedora
' Non-Ubuntu/Fedora-specific thing
@endif
@elseif MacOS
' MacOS-specific thing
@endif
@endif |
_________________ Brent |
|
Back to top |
|
|
STPendl Full Member
Joined: 20 Aug 2007 Posts: 161 Location: Austria
|
Posted: Mar 30th, 2012, 7:49am Post subject: Re: Experiment - Compiler directives |
|
|
That makes sense too, so specifying a constant for the path separator or path list delimiter would be easy. _________________ Stefan
Any code I post can be freely used, just give credit. |
|
Back to top |
|
|
|