User:Dan Bron/Temp/IsEvokeBroken
Discussion of the ~ bug report continued:
Discussion
- I'm not sure that this is a bug. I think this behavior fits what the dictionary says about resolution for verbs: verbs are resolved as names, and the name is used at evaluation time to determine the context for execution. Here's a definition of evokeU that does what I think you want:
evokeU=:1 :'(5!:1<''u.'')5!:0' -- ["Raul Miller"] DateTime(2006-05-22T19:39:30Z)
- I considered that interpretation; see the last example on this page.
Clearly, + 1 : '''u''~'' is producing 'u'~: a single name to be executed (contrast + 1 : ' $ ''u''~'). The problem is that the name is executed in global (immex) context, not local context. Where is that behavior is described by the Dictionary? Here are the quotes I believe relevant:
A. First, verify that u is is a valid name:
qNM =. 2080 200 qdoj 'dict1' qNM #~ -. (+.~:/\) '()' e.~ djqNM=. CRLF-.~ djqNM Names begin with a letter and may continue with letters, underlines, and digits. NB. Definition to test for "name"-ness ld =. ; 'ltr dgt' =. ;: 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789' isName =. (ltr ,&:< ld) *./@:(;@:(e.&.>)~ {. ,&:< }.) }}} and
qVLD =. 1019 148 qdoj 'dx004' LF (] #~ ] -.@:E.~ 2 # [) CR -.~ djqVLD 4!:0 y Name Class. Class of (boxed) name: _2 invalid NB. Definition to test for "valid name"-ness validName =. (_2 -.@-: 4!:0) @: (;: ^: (0 -: L.)) }}} therefore
NB. u is a valid name + 1 : ' (validName *. isName) ''u'' ' 1
A. Then support the expectation of its value:
qARG =. (CRLF,'()') -.~ 3654 389 qdoj ':' NB. Moreover, it refers to the adverb's argument _15&(]\)&.;: qARG {~ <<< ; _2 <@:(+ i.)/\ 253 14 156 58 117 15 88 16 81 3 56 12 24 19 The names x and y denote arguments. a conjunction may refer to its arguments using u and v ; likewise , an adverb may refer to its using u
A. Finally, invoke the evoke rule:
]qEVK =. 1071 73 qdoj '~' If m is a name, then 'm'~ is equivalent to m }}}.
Given these quotes, I assert the Dictionary says
+ adverb define 'u'~ )
and
+ adverb define u )
are equivalent, but the interpreter says they're not. Can you argue, from the text of the Dictionary, that this is not a bug?
Obviously, to do so is merely an exercise. The behavior is not a an obstacle in real life, as your code aptly demonstrates (thanks for that; I have a similar utility in my scripts).
On top of that, the deprecation of the special inflected names u.v.m.n.x.y. rendered it even more ambiguous. After all, what's the difference between 1 :'''u''~' and 1 : '''global_function''~'?
On the other hand, consider 1 : ('local_function=.+/';'''local_function''~')...
-- Dan Bron <<DateTime(2006-05-23T00:09:16Z)>>
- As I understand the dictionary, the following lines executed in typical j session should always give the indicated result. Furthermore, the lines can be re-arranged and, as long as the final line is left as the final line, the result should be the same.
a=:b b=:c d_e_=:3 :'noun' noun_e_=:i.3 noun=:'abc' c=:d_e_ a 1 0 1 2 }}}[[BR]][[BR]]Perhaps you are arguing that local names should get special treatment in the dictionary, but I don't think you can validly argue that the dictionary currently grants them the behavior you've implied, above.[[BR]][[BR]]-- ["Raul Miller"] [[DateTime(2006-05-23T05:23:07Z)]]
- I understood your point. What you are arguing is that the behavior is correct in the sense of:
+ adverb define q =. +/ q ) |value error: q }}} But what I am arguing is that the behavior is buggy in the sense of:
+ adverb define u =. +/ u ) +/ }}} Giving local names special treatment would eradicate the inconsistency demonstrated above (WRT `q` vs `u`). That might be a useful feature, but indeed a new one. That is, it would require a change to the Dictionary. I am not arguing otherwise.
My argument is that J should be consistent about giving __special__ names special treatment. Those special names are the are the pre-assigned argument referents, which previously were inflected.
In short: I just want the sentence "If m is a name, then 'm'~ is equivalent to m" to be true.
-- Dan Bron <<DateTime(2006-05-23T15:25:10Z)>>
- This, I think, is a different issue -- not related to evoke.
What you are talking about here is that (for reasons that I don't think are documented in the dictionary) some local variables get treated differently from others.
That said, I see what you are saying -- I just don't think it's the right thing for locative names. Consider x__y as an example.
-- Raul Miller <<DateTime(2006-05-23T20:18:16Z)>>
- I don't understand that last paragraph. Where did locatives come in? Now that you've brought them up, though, wouldn't you prefer a different result for the last two sentences here?
x_z_ =: 42 3 : ' x__y ,&< ''x__y''~ ' {.;:'z' ┌──┬──┐ │42│42│ └──┴──┘ 'abc' 4 : ' x__y ,&< ''x__y''~ ' {.;:'z' ┌──┬──┐ │42│42│ └──┴──┘ 'abc' 2 : ' x__y ,&< ''x__y''~ ' ({.;:'z') ┌──┬──┐ │42│42│ └──┴──┘ x_z_ =: +/ 'abc' 2 : ' x__y ,&< ''x__y''~ ' ({.;:'z') x__y ,&< x__y 'abc' 2 : ' x__n ,&< ''x__n'~ ' ({.;:'z') x__n ,&< x__n }}} -- [[User:Dan Bron|Dan Bron]] [[DateTime(2006-05-26T16:14:45Z)]]