bug-apl
[Top][All Lists]
Advanced

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

Re: [Bug-apl] Subtle parsing problem


From: Juergen Sauermann
Subject: Re: [Bug-apl] Subtle parsing problem
Date: Tue, 29 Jul 2014 13:55:35 +0200
User-agent: Mozilla/5.0 (X11; Linux i686; rv:17.0) Gecko/20130330 Thunderbird/17.0.5

Hi Elias,

this is because your lambdas are niladic. The right lambda is called before SEL,
while the left lambda is called by SEL. From SEL's perspective, 'then'; is a function
while 'else' is a value.

/// Jürgen


On 07/29/2014 07:21 AM, Elias Mårtenson wrote:
I was writing an operator that acts as an "if"-statement, calling one of two functions depending on the value of the argument:

∇Z ← (then SEL else) arg
  →(arg=1)/do¯then
  →(arg=0)/do¯else
  ⎕ES 'Illegal value for arg'
  →0
do¯then:
  Z ← then arg
  →0
do¯else:
  Z ← else arg


Note that the then and else functions are called with an argument "arg". When I call this operator with two nihilic lambda functions, I get very strange behaviour:

      ⊣ ({⎕←'was true'} SEL {⎕←'was false'}) 0
was false
      ⊣ ({⎕←'was true'} SEL {⎕←'was false'}) 1
was false
was true

I would expect to get an error message here, or perhaps seeing (⎕NC '⍵') to be 0. I certainly didn't expect to see both functions be called. My suspicion is that there is a problem with the parser somewhere, but I think Jürgen will have to look at this one.

Regards,
Elias


reply via email to

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