Page 1 of 1

Soliciting feedback on compiler directives

PostPosted: Sun Mar 16, 2008 9:50 am
by Charles
An example compiler directive would be conditional compilation like C#'s "#if"

Another use would be to put cobra arguments at the top of a file.

But what should they look like? I don't want to double up any arithmetic operators since Cobra already does that for ** and // which are themselves arithmetic operators. @ and $ are reserved for future use. I don't think # is suitable as it's being used for comments.

I have some ideas, but I'd like to hear yours.

Re: Soliciting feedback on compiler directives

PostPosted: Sun Mar 16, 2008 4:52 pm
by dennis
How about a keyword instead of a special character?

cobra args -one-option -another

cobra if somecondition
cobra dosomething #nested compiler directive, e.g. to set an option
dosomemore #this gets compiled (deducting one indentation level*)
cobra else
dosomethingelse


The idea is that you're speaking to the compiler.

* for conditional compilation the "cobra" keyword would be indented at the level of the surrounding code and the result of satisfying the condition would then be returned at that level

Re: Soliciting feedback on compiler directives

PostPosted: Fri Dec 12, 2008 7:27 am
by jonathandavid
dennis wrote:How about a keyword instead of a special character?

cobra args -one-option -another

cobra if somecondition
cobra dosomething #nested compiler directive, e.g. to set an option
dosomemore #this gets compiled (deducting one indentation level*)
cobra else
dosomethingelse




I like this idea... Chuck, finally what was your decision on this regard?

Re: Soliciting feedback on compiler directives

PostPosted: Fri Dec 12, 2008 10:57 am
by Charles
I'm no longer reserving @ for other usage. So I'm currently leaning towards @foo as in @if, @args, etc.

I had thought of the "cobra foo" idea myself at an earlier time, and it's quite logical, but it just doesn't stand out from the rest of the code. Also @foo could be useful within a line of code like @show(foo.bar.baz) expanding to:

'foo.bar.baz=[CobraCore.toTechString(foo.bar.baz)]'

Re: Soliciting feedback on compiler directives

PostPosted: Sat Dec 13, 2008 4:14 am
by hopscc
FWIW I'm comfortable with the existing '%%' prefix at start of line

Code: Select all
%% warning pull up whoop whoop

%% number float32

%% args -ref:myLibNamedFunny


It stands out strongly from executable code and being wired to the start of line its not mistakeable for any sort of arithmetic operator.