Initialize a Field In-Line or Within a Constructor?

Writing and using Classes in Dyalog APL

Re: Initialize a Field In-Line or Within a Constructor?

Postby DanB|Dyalog on Sun Apr 17, 2011 6:01 am

Gil, Eric,
I am going over a few questions left pending from the forum:

I don't know if this can help here but
you can always define a fn with []FX that specifies the proper :Access as in

⎕FX'r←Find x' ':access public' 'r←Symbols∘⍳ x'

I don't know if/when Dyalog will implement :Method but this will work in the meantime.
The :method statement idea is a good one, I have made an RFE (Request For Enhancement) based on it. I think this is a better idea than having :field (which is a variable) accept fns.


[]EX a :field removes all its :access

The editor "sees" names even tho they are not visible from the outside. This is a new feature. Before you could not and people complained.

You should be careful about using non-documented "features" of the language as Dyalog may remove or modify them (this should go without saying). Best thing to do is to inquire before putting this into production.

Dyalog folllows C# closer than any other OO language but it is NOT C# nor is it C++.
Dyalog is typeless so it is VERY different from strongly typed languages like C++.
In C++ you can have several constructors which are only differenciated by their signature (their calling sequence & types).
In Dyalog you can't do that. You must have a different fn for each way to call the constructor.
You can argue that there could be another way to do this but it is a bit late in the game to do it now.
That being said it doen't mean it can't be improved.

Regarding :include in the documentation (I quote Morten):
:Include in Dyalog APL allows one or more classes to “inherit” the behaviour described by code that is held in one or more Namespaces, in addition to the code that is in the class itself. This allows you to share methods between several classes, which is one of the goals of multiple inheritance, as I understand it. So I think we can stand by the statement that it provides “A DEGREE OF” multiple inheritance.

/Dan
DanB|Dyalog
 

Previous

Return to Object Oriented Programming

Who is online

Users browsing this forum: No registered users and 1 guest