Hello,

Continuing on my experiment with the DSL I imagine...

Client Code:
obj =: bo 'customer'                NB. create is now called bo
obj add ('name';'MyName')

=========================================
This should result in :
0) An instance obj of type customer. (I used Bill's version here)
1) an attribute added to the class of obj
2) the attribute instantiated in the specific instance obj.

I tried the following (based on the above recommendations...) for the add
verb -

add =: 4 : 0
attr =. 0{::y
class =. ; {. @ copath x
s =. attr,'_',class,'_'
NB. s =: attr,'_',class,'_ =:', 1{::,y
". s
s =. attr,'__x',' =:', 1{::,y
". s
)

As you can see, I am creating strings and executing them.

Q1: Is there a simpler way to inject names into locales?

Then, I look at the names I have so far created:

  conames ''
0          1          2          base       customer   j          jgl2

jijs       jprint     jproject   jregex     jscriptdoc jview      y

z

  names_customer_ ''
  names__obj ''
COCREATOR name
  name__obj
+------+
|MyName|
+------+

Q2: Why is the names_customer_ empty? Is it because of lazy evaluation of J?
By this I mean that since the attribute is not assigned a value, the
namespace of 'customer' does not record the attribute called 'name'.

Q3: Later, I would like to apply reflection techniques to look into the
objects I have created of the various type (here instances of locatives) -
for this I assumed that I need to introduce the attribute in the class
and assign value to it in the object instance. But, with the issue mentioned
in Q2, I donot know how to proceed.

Thanks for any pointers here,

Yuva
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to