On Sun, 17 May 2009, Viktor Cerovski wrote:
>
>
> bill lam-2 wrote:
> >
> > On Sat, 16 May 2009, Tracy Harms wrote:
> >> invocation, and verbs must be defined prior to execution.
> >
> > IIRC undefined name are treated as verb. Suppose b is not yet defined,
> >
> > a=: 3 + b
> > a
> > 3 + b
> > b=: 1
> > a 10
> > |domain error: b
> > | a 10
> > b=: *:
> > a 10
> > 103
> >
> It's a bit more complicated. b is more like a free variable of universal
> type,
> which means it can become anything: noun, verb, adverb or conjunction.
>
> Such semantics is unusual (I can think only of Mathematica here),
> and the up side is that some things, like mutually recursive verbs, or
> parametric verbs, are easy to define, but the down side is that we
> don't know whether some expression with such a free variable will become
> well formed in the course of further interpretation or not, just as your
> example
> illustrates.
>
> Another apparently similar, but meaningless, expression is:
> c=:d+1
> |value error: d
> | c=: d+1
>
There ain't such thing as free variables in J evaluation stack. To see
why your expression raise an error, let's trace the immediate steps
using side effect
v1=: 1!:2&2
c=: d v1 1
1
|value error: d
| c=: d v1 1
the 4 entries in stack are
=: v v n
so v n is immediately reduced to a another noun, and become
=: v n'
now this should also be immediately reduced to yet another noun, but
since verb d is undefined, it can't proceed and thus raise an error.
As you have already noted, current behavior allows forward reference
for verbs.
Also a=: 3 + b will raise error in J504 because fork `n v v' is not
implemented. It is no difference from a=: 3 + * in that it is a syntax
error.
--
regards,
====================================================
GPG key 1024D/4434BAB3 2008-08-24
gpg --keyserver subkeys.pgp.net --recv-keys 4434BAB3
唐詩125 孟浩然 與諸子登峴山
人事有代謝 往來成古今 江山留勝跡 我輩復登臨
水落魚梁淺 天寒夢澤深 羊公碑字在 讀罷淚沾襟
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm