It probably is primitives only which can compute the shape of the
result from the shape of arguments alone.

The reason being that non-primitives need to deal with an arbitrarily
large verb space.

-- 
Raul


On Wed, May 11, 2016 at 7:38 PM, Henry Rich <[email protected]> wrote:
> That's the sort of rule I was looking for.  But more needs to be said to
> make it unambiguous, namely when the shape can be so computed, and what the
> shape of the (empty) result should be.
>
> For example, (+), (+"+), (p =: +), and (4 : 'x+y'"0) all do the same
> calculation, but the first gives an error when applied with rank 1, and the
> others don't.  Do we say 'the shape of the result can be computed from the
> shape of the arguments alone' when the verb is a primitive or, for
> primitives with IRS, the form primitive"n?  And should the shape of the
> result correspond to a literal reading of the fill-cell rule, as in my
> examples, or should it follow some other precept?
>
> It does seem incongruous to say that
>
> (i. 0 2) +"1 i. 0 3
>
> and
>
> p =: +
> (i. 0 2) p"1 i. 0 3
>
> should have different results.  But I am beginning to think that following
> the fill-cell rule does not produce the most desirable results either.  So I
> would like us (the J community) to think about how to nail down what should
> be the rules on the results of execution on empty arguments.
>
> Henry Rich
>
>
>
> On 5/11/2016 7:19 PM, Roger Hui wrote:
>>
>>
>>     A similar case is
>>
>>        (i. 0 2) +"1 i. 0 3
>>
>>     This fails with length error, but by the fill rules it should
>>     produce (0$0).
>>
>>
>> In my mind this is not a similar case.  There is a rule which may not
>> written down but should be written down, and the rule is this:  If the shape
>> of the result can be computed from the shape(s) of the argument(s) alone,
>> then that is done, and if no elements are involved (argument(s) are empty)
>> then you are done (return the result) without further ceremony.
>>
>>
>>
>>
>>
>> On Wed, May 11, 2016 at 1:00 PM, Henry Rich <[email protected]
>> <mailto:[email protected]>> wrote:
>>
>>     1. When a verb is executed on an empty argument, it executes on a
>>     cell of fills to find the shape of the result (using atomic 0 as
>>     the result if the execution fails)
>>
>>     2. The shape of (integerarray { otherarray) is ($integerarray,
>>     (shape of an item of otherarray)).
>>
>>     These are inconsistent.  It's not obvious, but here's an example:
>>
>>        (0$0) { i. 0 3
>>
>>     The x argument has a 0 in the frame, so it should execute on a
>>     cell of fills; that is, the verb should start by executing
>>
>>       0 { i. 0 3
>>
>>     This fails with index error, so the result of the fill-cell
>>     execution should be taken to be atomic 0, and the overall result
>>     should have shape (,0).
>>
>>     It doesn't because (integer { array) is implemented as if { had
>>     infinite left rank.  ((0$0) {"{ i. 0 3) produces the correct result.
>>
>>     I fixed that, so that { produced the right result, but it broke
>>     something in sparse-array processing that depended on the old
>>     rules.  I am now wondering if there might be user code too that
>>     depends on this erroneous behavior.
>>
>>
>>       A similar case is
>>
>>        (i. 0 2) +"1 i. 0 3
>>
>>     This fails with length error, but by the fill rules it should
>>     produce (0$0).
>>
>>
>>       I would like to have a discussion about the right course of
>>     action with the JE.  We could:
>>
>>     1. Leave the current inconsistent behavior as is (yuk!).
>>     2. Make { conform to the spec, violating rule 2 above and possibly
>>     causing errors in the field
>>     3. Others?
>>
>>     Henry Rich
>>
>>
>>
>
> ----------------------------------------------------------------------
> 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