[Jprogramming] val__u in adverb and conjunction

Henry Rich HenryHRich at nc.rr.com
Sat Apr 1 19:57:03 HKT 2006


It looks like an error in the interpreter, but one you can work around.

The interpreter scans the text of the entity looking for the variables
m. n. u. v. m n u v
and if it doesn't find any, it assumes that x and y actually mean
u and v.  It apparently doesn't recognize val__u as being a reference
to u, so it translates x and y into u and v; in a1, for example, this
makes y undefined, because there is no v operand to the conjunction.

Before J6 you would have had to have a line like
u =. u.
which would alert the interpreter that u. is used.  Now you have
to make sure that u or v appears by itself somewhere in your
entity.  One way is

   a4 =. 1 : 'if. do. u else. y+val__u end.'

Maybe Gosi was right, and we should get rid of the old-form
modifiers for J6.

Henry Rich



> -----Original Message-----
> From: programming-bounces at jsoftware.com 
> [mailto:programming-bounces at jsoftware.com] On Behalf Of Mikl Kurkov
> Sent: Saturday, April 01, 2006 6:15 AM
> To: programming at jsoftware.com
> Subject: [Jprogramming] val__u in adverb and conjunction
> 
> I want to use numbered locale as a parameter for adverb and 
> conjunction.
> But I stucked with problem, that sometimes I'm allowed to use 
> val__u, and  
> sometimes not.
> I worked out that this can be avoided by assigning u value to 
> another  
> local variable.
> But I want to understand why it's impossible to just use val__u.
> 
> NB. Test code
> coclass 'test'
> create =: 3 : 'val =: 20'
> destroy =: codestroy
> 
> cocurrent 'base'
> t =: '' conew 'test'
> a1 =: 1 : 'y + val__u'
> a2 =: 1 : 'y + val__u1 [ u1 =. u'
> c1 =: 2 : 'y + val__u + val__v'
> c2 =: 2 : 'y + val__u + v'
> 
> t a1 10
> |value error: y
> |       y+val__u
> 
> t a2 10
> 30
> 
> (t c1 t) 10
> |domain error: c1
> |   y    +val__u+val__v
> 
> NB. but next is working
> (t c2 10) 30
> 60
> 
> NB. and this one works too
> c3 =: 2 : 'y + u + val__v'
> 
> (10 c3 t) 30
> 60
> 
> NB. but this not
> c4 =: 2 : 'y + val__v'
> (10 c4 t) 30
> |domain error: c4
> |   y    +val__v
> 
> So can you explain this behaviour
> and is it better to avoid using something like val__u in adverbs and  
> conjunctions?
> 
> -- 
> Mikl
> ----------------------------------------------------------------------
> For information about J forums see 
> http://www.jsoftware.com/forums.htm



More information about the Programming mailing list