> [EMAIL PROTECTED] On Behalf Of Oleg Kobchenko
[...]
> By "simple" I meant order of complexity.
> Of course you would want just to use regular
> expressions to look for y. which will not be
> part of try. for_y. or "That's easy."
> 
> One of the objections to y.->y was that it
> would take place of user names y, x, etc,
> So to make this reversible, you need also to
> replace those names with something else,
> like X, Y or nx, ny, etc,
> 
> 

I can be more complicated (deeper) than the above for an, admittedly, small
minority that likes to write programs that write and execute programs (as it
is explained in the message below).   

> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
> Behalf Of Fraser Jackson
> Sent: Thursday, April 13, 2006 10:17 PM
> To: Beta forum
> Subject: Re: [Jbeta] x and y variables
> 
> My initial reaction to this change was to favour it.  Oleg's message
> expresses much better than I could its potential advantages.
> 
> However it does impose a new discipline in thinking about names in
> definitions - it is essential to recognise that the first occurence of an
> x
> or y (or m n u v) in an assignment obliterates the function argument.
> 
> A very powerful feature of J is that it permits construction and execution
> of code from function arguments.  With this change it is clearly dangerous
> to
> execute such code before all references to the function arguments are
> complete
> or have been protected by saving the argument values.
> 
> The following simple example of test illustrates a case where both x and y
> are recoded by  ". even though there is no apparent reference to y on the
> left of a copula - the reference is in the data supplied argument.
> 
>    test =: 4 : 0
> ". '''',x,'''=.y'
> x;y; ". each ;:x
> )
> 
>    'a b c' test i. 3 5
> +-----+--------------+---------+---------+--------------+
> |a b c| 0  1  2  3  4|0 1 2 3 4|5 6 7 8 9|10 11 12 13 14|
> |     | 5  6  7  8  9|         |         |              |
> |     |10 11 12 13 14|         |         |              |
> +-----+--------------+---------+---------+--------------+
>    'x y z' test i. 3 5
> |domain error: test
> |   x;y;".each    ;:x
> 
>    test1 =: 4 : 0   NB. uses inflected names
> ". '''',x.,'''=.y.'
> x.;y.; ". each ;:x.
> )
> 
>    'a b c' test1 i. 3 5
> +-----+--------------+---------+---------+--------------+
> |a b c| 0  1  2  3  4|0 1 2 3 4|5 6 7 8 9|10 11 12 13 14|
> |     | 5  6  7  8  9|         |         |              |
> |     |10 11 12 13 14|         |         |              |
> +-----+--------------+---------+---------+--------------+
>    'x y z' test1 i. 3 5
> +-----+--------------+---------+---------+--------------+
> |x y z| 0  1  2  3  4|0 1 2 3 4|5 6 7 8 9|10 11 12 13 14|
> |     | 5  6  7  8  9|         |         |              |
> |     |10 11 12 13 14|         |         |              |
> +-----+--------------+---------+---------+--------------+
> 
> The function test1 with the inflected form creates no difficulty.  I am
> afraid I very much dislike code which has unintended side effects
> dependent
> on data provided at execution time.
> 
> This change now means we have two classes of nouns.  Those which we can
> code
> as we always have, and the small group of single character names where we
> have to explicitly consider possible side effects from their use as
> placeholders as well.
> 
> I am not against getting rid of the inflection for placeholders - an
> alternative I have used is the conjunction  'of' in
> system\packages\misc\fndef which permits definitions of the form
> 
> trianglearea =: function of 'height base'
> 0.5*base*height
> )
> 
> Newbies and young users can understand that form of definition very
easily,
> but it is much simpler to code when the place holders are inflected names
> and thereby distinguished from the usual alphameric set of variable names.
> 
> Fraser
> 
> ----------------------------------------------------------------------
> 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