When I first came across Self-Reference ($:), in my naivety I expected to be able to write:
max=: 3 : 0 $:/ y : x >. y ) in lieu of: max=: 3 : 0 max/ y : x >. y ) ...but replacing max with $: fails here with: stack error. $: seems to be saying to me: "I'm being called monadically, so that's how it's going to stay". In other words, it's appealing here to its lower self, not its higher Self. This isn't the case with the tacit counterpart: max=: (max/) : (>.) NB. parens are redundant, see: 5!:5 <'max' max=: ($:/) : (>.) ...both of which work fine. Now, whilst I can appreciate the behaviour of $: as an implementation convenience -- maybe an imperative -- I cannot come up with a plausible "user model". To HF people this is the mental construct you offer the user (appropriate to his or her background and training) avoiding a direct appeal to the implementation -- it being a mark of a high-level language that the latter is free to change at some future date. The Dictionary definition is: "$: denotes the longest verb that contains it" -- which is commendably brief, as user models go. But I can't see how to apply it to the present case, where $: doesn't appear to "denote" -- or rather deliver -- the whole of verb: max, but only the part above the colon. Does it require modification, eg to: "the longest tacit verb that contains it"? It's not just for my edification. NuVoc readers may appreciate an explanation. I offer the following script as an anatomy of the issue ... NB. =========================== NB. p -uses raw primitive: >. NB. m -uses $: NB. M -uses own name NB. *ax -tacit NB. *AX -explicit pax=: (>./) : (>.) pAX=: 3 : 0 >./ y : x >. y ) max=: ($:/) : (>.) NB. the parens happen to be redundant here mAX=: 3 : 0 $:/ y NB. stack error in monadic : x >. y ) Max=: (Max/) : (>.) MAX=: 3 : 0 MAX/ y : x >. y ) foo=: 3 : 0 for_f. y do. smoutput (>f) , '=: ' , 5!:5 f 0!:111 (>f),' 3 4 5' NB. eg: max 3 4 5 0!:111 '3 ',(>f),' 5' NB. eg: 3 max 5 smoutput '----' end. ) foo ;: 'pax pAX max mAX Max MAX' NB. =========================== ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
