Forums

properties in mixins

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

properties in mixins

Postby kobi7 » Sun Nov 11, 2012 4:24 am

the following code doesn't compile due to "error: Cannot use the from form of a property inside an interface declaration."
refering to the getter.

Are properties prohibited in mixins, or is this a mistake?

Code: Select all
mixin ManageAttitude

   var _attitude as decimal
   get attitude from _attitude

   def happierBy(n as decimal)
      require
         n >= 0.0 and n<=1.0
      body
         _attitude = Math.min(1.0, .attitude + n) # atmost

   def sadderBy(n as decimal)
      require
         n >= 0.0 and n<=1.0
      body
         _attitude = Math.max(0.0, .attitude - n) # atleast


Thanks, kobi
Falun Dafa is Good.
Truth, Compassion, Forbearance is Good.
kobi7
 
Posts: 82
Location: Israel

Re: properties in mixins

Postby Charles » Sun Nov 11, 2012 1:28 pm

Properties are definitely allowed. This is a code gen bug. Until it's fixed, the workaround is to write the code for the property like so:
mixin ManageAttitude

var _attitude as decimal
get attitude as decimal
return _attitude
Charles
 
Posts: 2515
Location: Los Angeles, CA

Re: properties in mixins

Postby Charles » Sun Nov 11, 2012 11:37 pm

This is fixed now.
Charles
 
Posts: 2515
Location: Los Angeles, CA

Re: properties in mixins

Postby kobi7 » Tue Nov 13, 2012 3:40 am

wow, thanks for the prompt replies and fixes.
I feel like a valued customer ;-)

support is much appreciated, and often underrated.
Falun Dafa is Good.
Truth, Compassion, Forbearance is Good.
kobi7
 
Posts: 82
Location: Israel

Re: properties in mixins

Postby Charles » Wed Nov 14, 2012 3:00 am

You're welcome.
Charles
 
Posts: 2515
Location: Los Angeles, CA


Return to Discussion

Who is online

Users browsing this forum: No registered users and 10 guests