bug-apl
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Bug-apl] ⎕ES wrong message


From: Kacper Gutowski
Subject: Re: [Bug-apl] ⎕ES wrong message
Date: Mon, 14 Jul 2014 18:44:29 +0200
User-agent: Mutt/1.5.23 (2014-03-12)

Whoops, this thread was about the message rather than return value.
About that, standard states that event-message is local to a context and
that ⎕ES should create an exception in caller's context, but I don't
think it's properly specified what does it exactly mean.

But the point is, that ⎕ES _is_ a part of the standard, not just APL2.


Anyway, regarding the result.

On 2014-07-14 10:09:02, Blake McBride wrote:
> That "return nil" is clearly a typo and a further reflection of the poor
> quality of that spec.

Admittedly standard is hard to read and underspecified in many places
but this is not the case here.

Look at 5.3.4.1:
>> – Result: A metaclass containing *nil* and the members of *exception*
>> and *value*.

Actually "return nil" is not a typo, but *nil* is not a *value*.
Every function that terminates returns _something_ in standard's
parlance — be it a value or an exception, or just nil — but it has
a result.

Returning nil is having the same result as that of a defined function
whose header doesn't start with Z←, i.e. without return value.

> I offer the following as proof that that comment is a
> typo:
> 
> 1.  Look at the signature of ⎕ES at the beginning of 11.5.7.  It says:
> 
>     ⎕ES  B
> 
> it does not say:
> 
>     Z←⎕ES  B
> 
> like they do everywhere else when a quad function returns something.

Form Z←Something is consistently used when Something returns a value.
But ⎕ES never returns any *value* according to the standard so it would
be incorrect to write Z←⎕ES B.  In fact, it should result in value error.

> 2.  In IBM APL 2 ⎕ES never returns a value.
> 
> 3.  Having ⎕ES return a value did cause me an unnecessary problem.

Yes, and the standard is on your and APL2's side here.
No value shall be returned, result shall be nil.

> 
> Where they day "return nil", they should have said "return".

Look at 5.4.1 which justifies that wording:
>> – Return X: An evaluation sequence phrase used to specify that
>> evaluation of this evaluation sequence is to stop and that a *token*
>> is to be returned to the caller of the evaluation sequence. If X is
>> a *token*, then X is returned; if X is an *array*, a *token* of
>> class *constant* and content X is returned.

Nil is not an array; nil is a token.  The standard doesn't say what would
"return" without an object mean.

The standard consistently uses verb "to return" for all kinds of results,
not only values; for example *signaling* an error also means that error
is _returned_:

>> – Signal X: An evaluation sequence phrase used to specify that
>> evaluation of this evaluation sequence is to stop and that a *token*
>> whose class is X, where X is an error, is to be returned.


-k



reply via email to

[Prev in Thread] Current Thread [Next in Thread]