I think (but I do not know for sure) that in the explicit case, the code gets flagged for special handling when the verb (or adverb or conjunction) is being defined. And, I think the code that is doing the flagging is rather simple -- it's checking to make sure there are no syntax errors, and is designed to be fast. It sees the assignment with this code and builds a special copy of the representation of that line.
So... if this was correct... the underlying mechanisms (that the recognition code is built on) are not there for the more general case. This means that the interpreter does not have to pay a speed penalty for the general case (and, while the actual evaluation is faster you need to also keep in mind that the code analysis is not instant, and you have to wait for it to execute every time it runs). If J were redesigned to perform this kind of code analysis every time } was used, it might, for example, delay execution of ,: which would cause other problems: Every operation would be slower (because every operation would now have to check to see if it was being passed a delayed ,: before it could do anything else). J would be a larger program (because every operation would need new code). J would probably have new bugs (because all of this new code will need to be debugged after it's implemented). So that particular implementation is probably a bad idea. Another variation might involve a re-designed parser (which would also add complexity and add new opportunities for bugs). This one might actually be worthwhile, if it could do a better job of supporting special code than the current one does. But designing a new parser system which does not change the language syntax and does the analysis needed for this kind of special code (and which is still fast enough) is no small task. But you if you feel like designing and implementing one, it would be a very interesting project. (I imagine that an "efficient" implementation would introduce and manage the deferred execution needed for the various sorts of special code. It's "just a small matter of engineering" to make that kind of thing worth using.) -- Raul On Thu, Dec 22, 2011 at 12:58 PM, David Vaughan <purpleblue...@googlemail.com> wrote: > Why should there be any speed up just from assigning the phrase to a noun? > Surely in both cases the same code has to be executed, one will display the > result, one will store the result? > > ___________________________ > > David Vaughan > > On 22 Dec 2011, at 17:46, Raul Miller <rauldmil...@gmail.com> wrote: > >> Actually, I think he was asking why the speedup is not available without the >> =: >> >> And I think that has to do with "ease of implementation". >> >> Also, if there's no =: then that syntax is almost certainly being used >> to generate a noun -- it's not being used to build a repeatable >> operation. You'd have to use different syntax to generate a useful >> verb. >> >> -- >> Raul >> >> On Thu, Dec 22, 2011 at 12:24 PM, Devon McCormick <devon...@gmail.com> wrote: >>> In a word: performance. >>> >>> a=. 1e6?@$0 >>> b=. <:+:1e6?@$0 >>> c=. 1e6?@$2 >>> >>> 10 ts 'r=. c}b,:a' >>> 0.0066557413 8390912 >>> 10 ts 'c}b,:a' >>> 0.021307987 41945088 >>> >>> >>> On Thu, Dec 22, 2011 at 11:00 AM, Johann Hibschman >>> <jhibsch...@gmail.com>wrote: >>> >>>> Thanks, everyone. I never understood item-amend until now. That's >>>> exactly what I was looking for. For context, I was reading through the >>>> APL book and hit the "/a,u,b/" notation, and wondered how to do that >>>> in J. >>>> >>>> One question though: why is the particular form (result=:c}b,:a) >>>> singled out, rather than the general (c}b,:a)? >>>> >>>> On Wed, Dec 21, 2011 at 10:54 AM, Henry Rich <henryhr...@nc.rr.com> wrote: >>>>> Note that >>>>> >>>>> c}b,:a >>>>> >>>>> does indeed compute b,:a. But if it's used in the precise form >>>>> >>>>> result =: c}b,:a >>>>> >>>>> the computation is avoided. >>>>> >>>>> b =: 1e6$4 >>>>> a =: 1e6$4 >>>>> c=: ? 1e6$ 2 >>>>> ts 'c}b,:a' >>>>> 0.0401299 2.09725e7 >>>>> ts 'q =: c}b,:a' >>>>> 0.0112949 4.19558e6 >>>>> >>>>> There are other special cases; see the Special Code page. >>>>> >>>>> Henry Rich >>>>> >>>>> On 12/21/2011 11:43 AM, Marshall Lochbaum wrote: >>>>>> A more obvious way is to use (c { b,.a) . The key is to realize that >>>> saying >>>>>> (if c then a else b) is just selection: if c is 0, we pick b, and if c >>>> is >>>>>> 1, we pick a. So we rephrase as (c { b,a), and J's implicit rank allows >>>> us >>>>>> to do (c { b,.a) for vector c, a, and b. >>>>>> >>>>>> That said, (c} b,:a) is faster, and uses less memory by not actually >>>>>> computing b,:a . So it's a better choice. >>>>>> >>>>>> Marshall >>>>>> >>>>>> On Wed, Dec 21, 2011 at 10:26 AM, Brian Schott<schott.br...@gmail.com >>>>> wrote: >>>>>> >>>>>>> One way is the following. >>>>>>> >>>>>>> c}b,:a >>>>>>> 10 2 30 >>>>>>> >>>>>>> >>>>>>> -- >>>>>>> (B=) >>>>>>> ---------------------------------------------------------------------- >>>>>>> For information about J forums see http://www.jsoftware.com/forums.htm >>>>>>> >>>>>> ---------------------------------------------------------------------- >>>>>> For information about J forums see http://www.jsoftware.com/forums.htm >>>>>> >>>>> ---------------------------------------------------------------------- >>>>> For information about J forums see http://www.jsoftware.com/forums.htm >>>> ---------------------------------------------------------------------- >>>> For information about J forums see http://www.jsoftware.com/forums.htm >>>> >>> >>> >>> >>> -- >>> Devon McCormick, CFA >>> ^me^ at acm. >>> org is my >>> preferred e-mail >>> ---------------------------------------------------------------------- >>> For information about J forums see http://www.jsoftware.com/forums.htm >> ---------------------------------------------------------------------- >> For information about J forums see http://www.jsoftware.com/forums.htm > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm