Page 1 of 1

Objects and Prototypes

Posted: Fri May 13, 2011 1:50 pm
by Erik.Friis
It appears that prototypes do support objects which is great and makes my coding cleaner for sure, but I ran into this strange behanviour:

Code: Select all

:class FooClass

:field public x

{del}FooClass
:implements constructor
:access public

x<-''
{del}
:endclass

:class BarClass

:field public x

{del}BarClass z
:implements constructor
:access public

x<-z
{del}
:endclass

Foo<-0{reshape}[]NEW #.FooClass
Foo.x


Bar<-0{reshape}[]NEW #.BarClass ''
LENGTH ERROR
Bar.x
^


Can anyone tell me why I am getting the LENGTH ERROR on Bar.x????

Re: Objects and Prototypes

Posted: Fri May 13, 2011 2:59 pm
by Erik.Friis
Well in speaking with Stanley Jordan he suggested that I implement a niladic constructor in BarClass and this seems to work. So it seems that a niladic constructor is invoked on the expression Bar.x where Bar is an empty vector containing an object (class?) prototype.