Page 1 of 1

behaviour of pro name from varname as type?

PostPosted: Mon Jan 18, 2010 6:41 pm
by gauthier
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?

Re: behaviour of pro name from varname as type?

PostPosted: Tue Jan 19, 2010 2:21 am
by Charles
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.

Re: behaviour of pro name from varname as type?

PostPosted: Tue Jan 19, 2010 2:22 am
by Charles
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.