Hello Oleg,

As advised I am going through the labs again.

For now, can you explain what you have suggested below?
a) what does '(x) := y' do?
b) why have you added this into the z locale? Is it to make it a global?
c) what does 'set__x/y' do? set_z_ is defined as a dyad. I donot see how the
arguments are being passed to set_z_ here.

Thanks,
Yuva


On 12/22/06, Oleg Kobchenko <[EMAIL PROTECTED]> wrote:

Here's what you need:

set_z_=: 4 : '(x)=: y'
add_z_=: 4 : 'set__x/y'

   obj=: cocreate''
   names__obj''

   obj add 'name';'MyName'
MyName
   names__obj''
name
   name__obj
MyName


--- Yuvaraj Athur Raghuvir <[EMAIL PROTECTED]> wrote:

> 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
>


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

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

Reply via email to