Agree with most of this, would only make two notes:

1) 

Things like += are most likely to be applied to true local variables, so 
locatives are irrelevant and the differences between =: and =. are relevant 
(the primary purpose of my response to your modf was to point this out)

2)  

I like your tacit/explicit hybrid code and it has a some advantages over the 
hybrid that I posted.   

Now, I don't think it would be common for f to be multi-line:  the likely use 
case is that f is trivial, as in + (because += et al are used to make a common, 
trivial, operation on temp vars more convenient).  

Furthermore, the longer and more complex f is, the less value modf is adding 
(ie the less difference there is between f = f u y and f u= y).  

And, again, the use of modf is likely within expl def, so it's very unlikely 
that f is an anonymous multi-line verb (and of course any named verb can always 
fit on one line).  

All that said, I appreciate the value of a general solution, and also the 
difficulties of applying 5!:5 to multiline verbs (and while it would be better 
to use 5!:6, the same difficulties would remain).  

But note that half the difficulty is due to the fact that we need a single line 
definition in the first place, which is a restriction of ". .  

To that
point, we could use 0!: instead, which is like ". but accepts arbitrary J 
scripts (and we might use 5!:7 to produce these scripts, where appropriate).

 -Dan


Please excuse typos; composed on a handheld device.

-----Original Message-----
From: Raul Miller <rauldmil...@gmail.com>
Date: Wed, 21 Apr 2010 14:18:11 
To: Programming forum<programming@jsoftware.com>
Subject: Re: [Jprogramming] f += 1

On Wed, Apr 21, 2010 at 1:05 PM, Dan Bron <j...@bron.us> wrote:
> IOW, normally what's wanted is f=.f+1 (not =:), of course explicit
> definitions cannot manipulate the local names within other explicit
> definitions.

Note that =: and =. are equivalent for locatives, and large code
bodies should probably be using locatives in appropriate
locales.

That said, here is a variation which uses =. instead of =:
linrep=:3 :'5!:5<''y'''
modfl=:1 :0
  [ ".@, '=.', [,' ',m,lin...@]
)

This version requires the verb to be quoted.  I did that because 5!:5
does not do anything useful for me, with multi-line verbs.

-- 
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

Reply via email to