If I understand correctly, the result of 0 : 0 may be referenced as any part of the expression on the same line; whether before, or indeed AFTER the 0 : 0. Conceptually, the lines following 0 : 0 (until the terminating ')') can be regarded as embedded in the 0 : 0 within the sentence. This is a curious design decision, but I think I understand how it works. (As noted to Henry, I'm not convinced it's adequately documented)
Regarding the 'heavy-handed' comment, I was just pointing out that ". is a very powerful, arguably the most powerful, verb. We are using it for a minor syntactic effect: nothing else. Analogously, ^: can replace +, which can replace >: (all dyadic). Similarly, @. can replace ^:, which can replace -. (dyadic here too). For code with maximum clarity, the 'least powerful' or 'most specific' verb/conjunction/... suitable for a task is most often preferred as it usually leads to the clearest code. On 12 Feb 2016 4:38 am, "Raul Miller" <[email protected]> wrote: > [posting my response in-line for context] > > On Thu, Feb 11, 2016 at 12:55 AM, Matthew Baulch <[email protected]> > wrote: > > Thanks everyone. This (let's say) creative use of 0 : 0 makes sense to me > > now. I wonder if it's an accidental consequence of the implementation > that > > allows an expression following the 0, or whether it's a deliberate design > > decision. Either way, it makes sense to have it documented. Can't see it > in > > NuVoc or the Dictionary. Of course, I may have overlooked it. > > http://www.jsoftware.com/help/dictionary/d310n.htm says > 0 : n noun > > So the result of 0 : 0 is a noun. (Specifically, it's a list of > characters.) So you should expect that anything you can do with a noun > you can do with a noun produced by 0 : 0 > > Or, that's how I read it... > > Note also that you can have multiple explicit definitions on the same > line. They pull their scripts from the input stream in the order that > they are parsed (mostly that's right-to-left). This can be fun to play > with, sometimes, but I guess it's usually better to give scripts > names. > > > Honestly, to obtain something simple like multi-line noun definitions, ". > > does seem like quite a heavy-handed tool. It does work however, so I > > probably shouldn't grumble. > > I'm not sure why you say that. > > One possibility is that ". cannot produce adverb or conjunction > results. (If that is the issue, you can resolve it by moving the > assignment statement inside the explicit noun.) > > Another possibility is that you would prefer a more heavy handed > approach (for example, moving an "ignore end of line" implementation > inside the interpreter and then changing other aspects of the > interpreter to taste.) > > But it's even more likely that I'm simply not following your thought > process. Would you care to elucidate? > > Thanks, > > -- > Raul > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
