Forums

Is this a bug? (Compile order on partial class files)

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

Is this a bug? (Compile order on partial class files)

Postby nevdelap » Fri Jul 16, 2010 12:23 pm

In this example test.cobra is just a file in the compile, test2.cobra and test3.cobra have two parts of a partial class, and test3.cobra needs Cairo.

It looks like the order of the files on the cobra command line requires that the file with the 'use Cairo' come first, but not just any file with the use has to be first, it has to be one of the files containing the parts of the partial class.

Is that a bug, or is it just something to be aware of when using partial classes?

I'm guessing it's a bug since if Thing inherit a class the compiler doesn't care which file i put that in, or which order the files are compiled, as long as it's not in both, so it seems it's not truly an ordering dependency on partials.

But if it's the later, what is the recommended course of action? 1/ put the same uses in the various files of the partial class, or 2/ manage the ordering dependencies for the compile?

Both seem ok if the compiler can't figure it out, but at the same time are not ideal, since obviously I only want uses in the files that need them. Are there many things that require specific orders of files in the compile?

Cheers,

N

Code: Select all
test.cobra
class Program
   def main
      pass

test2.cobra
use Cairo from Mono.Cairo
class Thing is partial
   def stuff
      pass

test3.cobra
class Thing is partial
   def draw(context as Context)
      context.stroke

cobra test.cobra test2.cobra test3.cobra (OK)
cobra test.cobra test3.cobra test2.cobra (No good)

Code: Select all
test.cobra
class Program
   def main
      pass

test2.cobra
class Thing is partial
   def stuff
      pass

test3.cobra
use Cairo from Mono.Cairo
class Thing is partial
   def draw(context as Context)
      context.stroke

cobra test.cobra test2.cobra test3.cobra (No good)
cobra test.cobra test3.cobra test2.cobra (OK)

Code: Select all
use Cairo from Mono.Cairo
test.cobra
class Program
   def main
      pass

test2.cobra
class Thing is partial
   def stuff
      pass

test3.cobra
class Thing is partial
   def draw(context as Context)
      context.stroke

cobra test.cobra test2.cobra test3.cobra (No good)
cobra test.cobra test3.cobra test2.cobra (No good)
call me Nev.
nevdelap
 
Posts: 61
Location: Buenos Aires

Re: Is this a bug? (Compile order on partial class files)

Postby Charles » Sat Jul 17, 2010 4:32 pm

I have run into this problem before. Cobra is indeed sensitive to the order of files when using partial classes. I consider this a bug, not a feature. I have always been able to quickly work around it by tweaking the order of the compilation, so it has been a low priority item. Please feel free to fill out a ticket.

Thanks.
Charles
 
Posts: 2515
Location: Los Angeles, CA


Return to Discussion

Who is online

Users browsing this forum: No registered users and 126 guests

cron