Assert Dfn

General APL language issues

Re: Assert Dfn

Postby Jay|Dyalog on Mon May 20, 2019 8:26 am

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.
Jay|Dyalog
 

Re: Assert Dfn

Postby Phil Last on Mon May 20, 2019 8:39 pm

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.
User avatar
Phil Last
 
Posts: 628
Joined: Thu Jun 18, 2009 6:29 pm
Location: Wessex

Re: Assert Dfn

Postby Jay|Dyalog on Tue May 21, 2019 8:51 am

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.
Jay|Dyalog
 

Re: Assert Dfn

Postby norbertjurkiewicz84 on Mon May 27, 2019 7:41 pm

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 ⍵}''
User avatar
norbertjurkiewicz84
 
Posts: 62
Joined: Mon Nov 01, 2010 7:26 pm

Previous

Return to Language

Who is online

Users browsing this forum: No registered users and 1 guest