Forums

behaviour of pro name from varname as type?

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

behaviour of pro name from varname as type?

Postby gauthier » Mon Jan 18, 2010 6:41 pm

I'm encoutering unexpected behaviour when using "from var" property implementation with example bellow that doesn't to compile

interface IFoo
get baz as int*
class Foo implements IFoo
var _baz = List<of int>()
pro baz from _baz as int*
class Program
def main is shared
pass


with
Code: Select all
c:\tmp\cobratickets\test.cobra(3): error: "Foo" does not implement interface member "IFoo.Baz". "Foo.Baz" is either static, not public, or has the wrong return type.
c:\tmp\cobratickets\test.cobra(2): warning: (Location of symbol related to previous error)
c:\tmp\cobratickets\test.cobra(5): warning: (Location of symbol related to previous error)
Compilation failed - 1 error, 2 warnings
Not running due to errors above.


workaround is to implement the property manually, but it feel strange to have the generated code expose ICollection (the c# compiler error message doesn't tell much without looking at offending code)

pro name from var <span style="font-weight: bold">as type</span>


what do you think this should emit?
gauthier
 
Posts: 116

Re: behaviour of pro name from varname as type?

Postby Charles » Tue Jan 19, 2010 2:21 am

I've never used "as type" after a "from var" but I don't have a problem with it if the type is the same or more general than the var's type. I can't get to this right this moment.
Charles
 
Posts: 2515
Location: Los Angeles, CA

Re: behaviour of pro name from varname as type?

Postby Charles » Tue Jan 19, 2010 2:22 am

I've never used "as type" after a "from var" but I don't have a problem with it if the type is the same or more general than the var's type. I can't get to this right this moment.
Charles
 
Posts: 2515
Location: Los Angeles, CA


Return to Discussion

Who is online

Users browsing this forum: No registered users and 83 guests