Objects and Prototypes

Writing and using Classes in Dyalog APL

Objects and Prototypes

Postby Erik.Friis on Fri May 13, 2011 1:50 pm

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

Postby Erik.Friis on Fri May 13, 2011 2:59 pm

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


Return to Object Oriented Programming

Who is online

Users browsing this forum: No registered users and 1 guest