On a fresh session, I was able to duplicate everything you said, and  reverting 
back to your original version was needed.  But then the more advanced objects I 
tried it on started to refer to dElEtEmE instead of the "right answer".  
Switching back to my version solved everything... restarting and not trying 
your 'a' OO2def 'base' test before that variable was assigned, produced the 
correct results too.

Here is a commented version... 

OO2def=:2 :0             NB. m: string of method/field, n: locale number (boxed 
optional)
NB. returns function that is either method or Get-field for the member m__n
  nm=.m refname n
  ".'t=.',nm             NB. trash variable
  if. 0=4!:0<'t' do.t=.".bind nm end. NB. if current value of field is noun, 
return field getter/reader
  (5!:1<'t')5!:0
)

A simple example of usage... is a fix for the bug I reported earlier.  Self 
contained version of Closure.

foo=: 2 : 0
  a=. cocreate''
  f__a=: u
  S__a=: n
  t__a =: 4 : '] S__x=: S__x  f__x  y'
  a & ('t' OO2def a)
)
   ] f =: + foo 3
] (<,'8')&t_8_
   f 2
5
   f 5
10
   f 0
10


----- Original Message ----
From: "Miller, Raul D" <[EMAIL PROTECTED]>
To: Programming forum <[email protected]>
Sent: Monday, October 30, 2006 5:57:25 PM
Subject: RE: [Jprogramming]  passing object functions to other objects

Pascal Jasmin wrote:

> on my version, this shorter version produces the same results,

> including passing your test case.

Odd, in a fresh session, I get:

   'a' OO2def 'base'

|value error: a_base_

   9!:14''

j601/2006-09-04/09:20

I've tried this on two different machines -- same behavior.

Also, if I define 'a', it still doesn't work right:

   a=:3 :'const+y'

   'a' OO2def 'base'

3 : 'const+y'

-- 

Raul


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