Forums

-compile-if-needed take into account a different -number?

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

-compile-if-needed take into account a different -number?

Postby nevdelap » Sun Jul 04, 2010 8:16 am

Hey.

Just want to get your opinion before I add something to trac.

Code: Select all
class Program
   def main
      assert 3.0.getType.toString == "System.Single"


If I was to compile this for the first time with -number:float32 it would work, correctly.
If I compile it again with -number:float64 it wouldn't work, correctly.
But if on the second compile I'd had -compile-if-needed it would have continued working, incorrectly.

I'm thinking that what's defined as 'if needed' might need to include if the already compiled program was compiled with a different -number setting than what's being attempted. I have no idea so far what that would entail in the compiler, and it's probably pretty edge case, but it could confuse someone at some point when it's in something non-trivial.

Code: Select all
nev@bananinha:~/Temp/cobra$ cobra -number:float32 test2.cobra
nev@bananinha:~/Temp/cobra$ cobra -number:float64 test2.cobra
An unhandled exception has occurred.
<snip>
Unhandled Exception: Cobra.Lang.AssertException: (Good)
<snip>
nev@bananinha:~/Temp/cobra$ cobra -number:float32 test2.cobra
nev@bananinha:~/Temp/cobra$ cobra -compile-if-needed -number:float64 test2.cobra
nev@bananinha:~/Temp/cobra$ (Oops!)
call me Nev.
nevdelap
 
Posts: 61
Location: Buenos Aires

Re: -compile-if-needed take into account a different -number

Postby Charles » Sun Jul 04, 2010 9:46 am

Other flags that could change results are -contracts -include-asserts -include-tests -include-nil-checks -include-traces -native-compiler -native-compiler-args (maybe) -ref -main

Not sure where to put that info though. I think we either come up with a solution that captures the flags somehow, or we simply document this shortcoming of -compile-if-needed.
Charles
 
Posts: 2515
Location: Los Angeles, CA

Re: -compile-if-needed take into account a different -number

Postby hopscc » Mon Jul 05, 2010 3:21 am

We discussed this around time of compile-if-needed implementation.
A solution mooted was to place some metainfo in the exe describing the compilation flags and check for flags change if -cif specified.
The situation was left as describing -cif as purely a timestamp based comparison which was all it was implemented as....
hopscc
 
Posts: 632
Location: New Plymouth, Taranaki, New Zealand

Re: -compile-if-needed take into account a different -number

Postby nevdelap » Mon Jul 05, 2010 3:01 pm

I suspected it was along those lines. I agree, best just highlighted in doco.
call me Nev.
nevdelap
 
Posts: 61
Location: Buenos Aires


Return to Discussion

Who is online

Users browsing this forum: No registered users and 81 guests

cron