Don Guinn-3 wrote: > > I don't understand what you mean by > >> >> 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. >> > > Any name can be reassigned from one type to any other type. That is, given > z=:1 can be followed by z=:+ reassigning it from being a pronoun to a > proverb. > That's exactly what I meant.
> Unknown names can be treated as verbs in some circumstances. > > d > |value error: d > z=.d > 4!:0<'z' > 3 > 4!:0<'d' > _1 > I agree. So what I was saying was that, exactly because we can assign any value to d, we could not know whether z would remain to be verb in the future, and that some expressions could even become ill-formed as a side-effect of some future assignment to some free variable like d. Such a problem does not happen in other languages with dynamic typing, such as LISP, Scheme or FL (because it is assumed there that evaluating an unassigned variable is an error), and it does happen in Mathematica (Mathematica attempts to always give a result for any entered expression, leading also to additional problems to this one). As far as the mutually recursive functions go, we could use f. : $ ~/j64-602/bin/jconsole f=:1:`(*f@<:)@.(1&<) f 10 3628800 u=:1:`...@.(1&<) v=:*u@<: u 10 3628800 If we were, however, to change v later on, definition of u would have also changed. f. helps here: f f. 1:`(* f@<:)@.(1&<) u f. 1:`(* u@<:)@.(1&<) Most importantly, f. deals correctly with free variables: F=:1:`...@.(1&<) F f. |value error: G | F f. So to establish referential transparency, we should also do u=:u f. after u has been defined. -- View this message in context: http://www.nabble.com/J-and-referential-transparency-tp23580460s24193p23607095.html Sent from the J Programming mailing list archive at Nabble.com. ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
