Starting from the end
P.S. The title for this thread is weird. This isn't about extending the @help concept. It's about new directives for conditional compilation.
If you reread the earlier posts you'll see its more about using the keyword + line (extended to a block)
syntax structure concept to provide conditional compilation (rather than an extension to help per se)
This is as opposed to implementing the same C-like preprocessor-ancestry general purpose variable set-unset and test branching structure. The problems issues and pitfalls of this are well known and later languages have all moved away from that concept ( at varying rates..)..
Actually this is all based loosely on D ( version2 of the lang rather than the 1.0 ref you linked to - not that theres very much difference/change)
Now to your points:
No OR / or ELSE
thats because theres no explicit 'if' or <condition>.
This is more oriented around a block (or statement or decl(s)- dont worry about the granularity)
thats triggered from a (fixed) condition tag - Its definitely
not directed towards arbitrary complex use as a general purpose branch-with-attendant-conditions setup
The 'conditional' in conditional compilation here is more to 'match' to a situation
( on a particular platform/backend, match to a user setting or a compiler setting) than a binary test of a boolean expression
env.var.'value' re other comparisons
there are no other comparisons - it matches or it doesnt.
(The number versioning was an afterthought - not sure its necessary or if need comparison to version numbers'
but could be done a similar way with something modifying what a match means
- Code: Select all
env.OSVer.'>=1.0'
as a rough (and poor) example.
The intention here is for something short and direct and keyword/tag like (that isnt similar to a binary condition).
word "version" (or "ver") doesn't conceptually describe "clr" and "jvm". Version is most often thought of as "0.9.3'
The second bit is a version-number not a version.
This is
version as in any conditional compilation makes a different version of the executable.
- version for jvm
- version for mono
- version for windows, ...
So no it doesnt describe the mechanism being tested/used, it describes the goal.
'a version specific to something'
The first sentence is an assertion not an argument.
The second sentence is factually correct but incomplete.
Its
one of the things D does. (after scrolling down) and it seems the least important one - the same page refers to 'Version Conditions' and 'Debug Condition' which are block oriented and more similar to the selection of code to compile we're after here.
No if-conditions for these common (and simple) cases.
- I'd say static-if in D was more for the benefit of their version of templating than conditional-compilation in that it tests compile time constants and a condCompile is directed by setups/config outside the codebase (target platform, user spec build defn passed into compiler,...)
.. description for reinvention of same-old C-preprocessor-like-ifdef for cobra elided....
I dont believe this is a desirable way to go for the most common cases
(code selection for platform, back-end, Debugging, compiler-setups).
At the very least its overly general purpose and complex for the need desired and subject to the same old problems and abuses...
Cobra deserves something simpler and clearer which tag-match-and-block definitely is.
The only thing to check for condCompile I havent covered is versioning on Cobra version (or more specifically cobra features per version).
Primarily I'm not sure its necessary ( at least it has not been to date) but over that
testing version and applying code specific to that version is not desirable to direct developers toward doing.
Pitfalls of this are well known as well.
Better is to form a code structure that ties versions to features then codes to the features
( as per the example on the D page just under 'Version Specification') - providing capability to do this would suffice for most uses
alternatively compiler could expose major feature items as condCompile match tags same as doing for platform/backend tags
(hasLambda, hasMethodInference, hasLiteralCollectionTyping...) assuming we can get some agreement of what constitutes a new major feature.
I agree that condCompile directives are not arbitrarily positionable - my impl has them only recognised in 3 places
(at statements, BoxMember decls, NSMember decls) - they're not separate from the tokeniser and recognised as unique parser items.
Also, any implementation needs a lot of tests. I found a couple bugs in Cobra just the other day. I'm trying to resolve this situation and get to 1.0 by emphasizing fixes over new features. Adding new features introduces new bugs. Lots of tests will be required
yeees.. There are tests with this covering all the inflection points as per usual - adding 'lots' probably wont improve coverage appreciably. This is same situation as everywhere else.
I'm not sure of your point here:
- there are bugs ?
- adding things introduces bugs?
- need more tests?
- no new features ?
- No code without tests ??
I agree that there is certainly no shortage of fixes waiting for something to be done with them without considering new features.
(OTOH having some simple form of condCompile would simplify porting tests for java backend massively so I'm scratching my own itch here)
I'm doubtful we need a "one line" form like what you showed for your var decls
Actually thats very useful - most noticeably with debug type output but also (wrt java port of tests) where theres a small one line tweak needed for support of different backends - saves a split of testfiles into two platform specific files or method differing in only a single line.
Its necessarily available for use, use of it is not mandated.
I would get @if working first and add convenience forms conservatively.
Aaah - I'm coming from the opposite position.
The 'convenience' forms (as you describe them) aren't - they are are the most-used core for condCompile (at least as it is now).
Only provide @if-@then-@else more general form for situations where the tag-match-and-block forms are totally unworkable.
(I'm not convinced thats the case or that the general form is advantageous in any form)
re OpSys.
For comparison most of the predefined version Identifiers in D are for specific OPSys implementations ( e.g Solaris vs 'unix')
cobra (currently) only supports 3 families (windows, mac and unix)
Will we (eventually perhaps) also need to become exactly platform/hardware/... specific for these builtins also (systems programming)?
Using @if/@else if/@else and expressions as a foundation seems fundamentally useful and clear
We're agreed on fundamentally useful (some form of condCompile). Clear - no
tagged-match and block-code is definitely clearer, cleaner and also stands out from cobra exec code (compared to cobra if-else branching).
I'll post the patch on the ticket and you can see some condCompiled test code.
I asked some specific questions in my earlier post - those were some directions I was wondering about since I thought I'd already clarified the general approach I was heading with this earlier.
(this is probably enough of a post for now - more later if I come up with anything else).