For Programmers: Free Programming Magazines  


Home > Archive > APL > January 2005 > Re: Distinguish primitive and defined functions inside an operator









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: Distinguish primitive and defined functions inside an operator
Mike Kent

2005-01-12, 3:55 am

Thomas Buchholz wrote:
> I wonder if there is a way in IBM APL2 for Windows to distinguish inside
> a defined operator whether or not the operator was called with some
> primitive function.
>
> Since there is actually no fill function implemeted for the Each
> operator I would like to mimic it using some defined operator E{<-}L(F
> EACH)R. In the monadic case the result of EACH on an empty R would
> therefore be E{<-}({rho}R){rho}{enclose}F{first}R if F is a primitive
> function and E{<-}R if F is a defined one. (BTW: does the Mainframe
> version really behave in that manner?)
>
> Any ideas would be gratefully appreciated.


Taking F as the left operand, look at the result of

'0' {[]}EA '{[]}CR''F'''

I believe this produces a detectable difference between defined and
primitive operands.
Mike Kent

2005-01-13, 8:57 am

David Liebtag wrote:
> Mike,
>
> I don't know why you used QuadCR inside QuaDEA, but whatever the reason, I
> don't think your example provides you with a way to detect whether the
> operand is primitive or not. You get the same result for locked defined
> functions as you get for primitives.


OK, but for many of us this is a theoretical limitation rather than
a practical one. I have not run into any locked code in the past
fifteen years or so.

Do you get the same result for external functions (i.e, are they
treated as locked)? That might be more of a practical issue.
Mike Kent

2005-01-14, 3:56 am

David Liebtag wrote:
> Mike,
>
> I don't know why you used QuadCR inside QuaDEA, but whatever the reason,


Because I don't have access to an APL2 system at the moment; the
OS/2 system I keep alive just so I can run APL2 is temporarily
out of service, I could not check that QuadCR won't throw an error
when applied to an operand name (for example, if the operand
is a derived function ...). So: I wrapped some exception handling
around the call to QuadCR.
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com