Objects and Prototypes

Writing and using Classes in Dyalog APL
Post Reply
Erik.Friis
Posts: 66
Joined: Mon Apr 04, 2011 3:16 pm

Objects and Prototypes

Post 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????
Erik.Friis
Posts: 66
Joined: Mon Apr 04, 2011 3:16 pm

Re: Objects and Prototypes

Post 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.
Post Reply