Assert Dfn

General APL language issues
Jay|Dyalog

Re: Assert Dfn

Post by Jay|Dyalog »

Phil Last wrote:Can I infer that a dfn lacking an unassigned expression would terminate with that last assigned, if any, as a shy result? I can imagine this causing a few headaches in debugging.


Yes, that's the behaviour I'd prefer. You may be right about headaches but I haven't noticed any myself.
User avatar
Phil Last
Posts: 628
Joined: Thu Jun 18, 2009 6:29 pm
Location: Wessex

Re: Assert Dfn

Post by Phil Last »

Jay|Dyalog wrote:I haven't noticed any myself

Perhaps you don't combine it with "techniques whose sole purpose is to avoid both assignment and termination". I should probably explain why I am so opposed to the trailing colon's use to avoid assignment. The programming reference guide contains:

    Multi-Line Dfns
    The single expression which provides the result of the dfn may be preceded by any
    number of assignment statements. Each such statement introduces a name which is
    local to the function.
The technique I'm questioning has two essentials:
    the expression must return zero which is not obvious unless coded as one of
      0⊣...
      {0}...
    and it must end in a colon, possibly made even less conspicuous by a trailing comment.
Thus when visually scanning a dfn we can easily be beguiled by such lines as
      calledFunction argument: ⍝ comment
that look very much as though they must supply the dfn's result. And I fail to see how the alternative
      z←calledFunction argument ⍝ comment

can be "undesired for aesthetic reasons" when it's merely a standard expression as described in the documentation.
Jay|Dyalog

Re: Assert Dfn

Post by Jay|Dyalog »

Phil Last wrote:Perhaps you don't combine it with "techniques whose sole purpose is to avoid both assignment and termination".


I should confess that I am also in favour of dfns continuing execution until the last statement, not stopping at the first non-assignment. That would be my preferred way of avoiding unwanted termination. (The last statement would supply the result of the dfn, which would be shy iff the statement was an assignment.)

But, I think it's fair to say, Scholes was never in favour of making this change.
User avatar
norbertjurkiewicz84
Posts: 62
Joined: Mon Nov 01, 2010 7:26 pm

Re: Assert Dfn

Post by norbertjurkiewicz84 »

Jay|Dyalog wrote:
Phil Last wrote:Perhaps you don't combine it with "techniques whose sole purpose is to avoid both assignment and termination".


I should confess that I am also in favour of dfns continuing execution until the last statement, not stopping at the first non-assignment. That would be my preferred way of avoiding unwanted termination. (The last statement would supply the result of the dfn, which would be shy iff the statement was an assignment.)

But, I think it's fair to say, Scholes was never in favour of making this change.



Not to mention simplifying .NET calls without an explicit result. No more code like

      _←netOB{6::0 ⋄ r←⍺.SomeFooWithoutResult ⍵}''
Post Reply