Cannot Return a Derived Function from a Public Method?

Writing and using Classes in Dyalog APL

Cannot Return a Derived Function from a Public Method?

Postby Erik.Friis on Tue Apr 12, 2011 8:38 pm

There must be some sort of implied property when returning a value from a public method outside of an object. In building my HashTableClass (will post code later) I thought I would provide an option of exposing the hash table derived function outside of the class. The code works fine (returning the derived function internally in the class)until you try to return it (the derived function) outside of the object - SYNTAX ERROR ...this was surprising to me and I was saddened to see this error, which tells me there is some property magic being invoked when something is returned outside of the object through the result of a public method. Yet another reason to ease this restriction on fields/properties and name classes. "r" is the result variable of the method and []nc 'r' is indeed 0 and allows the assign inside the object (as that character says in the cartoon "Wow, Wow, Wubsy": kooky.... :).
Erik.Friis
 
Posts: 66
Joined: Mon Apr 04, 2011 3:16 pm

Re: Cannot Return a Derived Function from a Public Method?

Postby gil on Wed Apr 13, 2011 5:34 pm

Good question...
Given the function Build in a traditional namespace #.Utilities

Code: Select all
    ∇ r←Build x
      :Access Public Shared
      r←x∘⍳∘{(⊂⍣(1=≡⍵))⍵}
    ∇


The following is fine:
Code: Select all
      myHash←Utilities.Build((⍳⍳3)'asd' ''⍬)
      myHash'asd'
2


Now define the class Hash as:
Code: Select all
:Class Hash
    :Include Utilities
:EndClass


Try again using the Build method from the Hash class and you get:
Code: Select all
      newHash←Hash.Build((⍳⍳3)'asd' ''⍬)
SYNTAX ERROR
      newHash←Hash.Build((⍳⍳3)'asd' ''⍬)
     ∧
gil
 
Posts: 71
Joined: Mon Feb 15, 2010 12:42 am


Return to Object Oriented Programming

Who is online

Users browsing this forum: No registered users and 1 guest