Forums

Soliciting feedback on compiler directives

General discussion about Cobra. Releases and general news will also be posted here.
Feel free to ask questions or just say "Hello".

Soliciting feedback on compiler directives

Postby Charles » Sun Mar 16, 2008 9:50 am

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.
Charles
 
Posts: 2515
Location: Los Angeles, CA

Re: Soliciting feedback on compiler directives

Postby dennis » Sun Mar 16, 2008 4:52 pm

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
dennis
 
Posts: 21

Re: Soliciting feedback on compiler directives

Postby jonathandavid » Fri Dec 12, 2008 7:27 am

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?
jonathandavid
 
Posts: 159

Re: Soliciting feedback on compiler directives

Postby Charles » Fri Dec 12, 2008 10:57 am

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)]'
Charles
 
Posts: 2515
Location: Los Angeles, CA

Re: Soliciting feedback on compiler directives

Postby hopscc » Sat Dec 13, 2008 4:14 am

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.
hopscc
 
Posts: 632
Location: New Plymouth, Taranaki, New Zealand


Return to Discussion

Who is online

Users browsing this forum: No registered users and 5 guests