From: Slobodan Blazeski
Subject: Why this doesn't work?
Date: 
Message-ID: <89ab6bb8-d756-435a-afb1-96f4c86bd93b@w34g2000yqm.googlegroups.com>
I assign the function to symbol-value but sometimes works sometimes
doesn't. What I don't understand?
(setq plus #'+)
#<Function + 20A6521A>

(mapcar plus '(1 2) '( 3 4))
(4 6)

(setq + #'+)
#<Function + 20A6521A>
CL-USER 14 : 5 > (mapcar plus '(1 2) '( 3 4))
(4 6)

(mapcar + '(1 2) '( 3 4))
Error: Argument to apply/funcall is not a function: (MAPCAR PLUS
(QUOTE (1 2)) (QUOTE (3 4))).
   1 (abort) Return to level 5.
   2 Return to debug level 5.
   3 Return to level 4.
   4 Return to debug level 4.
   5 Return to level 3.
   6 Return to debug level 3.
   7 Return to level 2.
   8 Return to debug level 2.
   9 Return to level 1.
  10 Return to debug level 1.
  11 Return to level 0.
  12 Return to top loop level 0.

Type :b for backtrace, :c <option number> to proceed,  or :? for other
options

From: ·····@franz.com
Subject: Re: Why this doesn't work?
Date: 
Message-ID: <8d12522b-45b4-4d64-b43c-8de8206f9358@e1g2000pra.googlegroups.com>
On Feb 11, 11:37 pm, Slobodan Blazeski <·················@gmail.com>
wrote:
> I assign the function to symbol-value but sometimes works sometimes
> doesn't. What I don't understand?
> (setq plus #'+)
> #<Function + 20A6521A>
>
> (mapcar plus '(1 2) '( 3 4))
> (4 6)
>
> (setq + #'+)
> #<Function + 20A6521A>
> CL-USER 14 : 5 > (mapcar plus '(1 2) '( 3 4))
> (4 6)
>
> (mapcar + '(1 2) '( 3 4))
> Error: Argument to apply/funcall is not a function: (MAPCAR PLUS
> (QUOTE (1 2)) (QUOTE (3 4))).
>    1 (abort) Return to level 5.
>    2 Return to debug level 5.
>    3 Return to level 4.
>    4 Return to debug level 4.
>    5 Return to level 3.
>    6 Return to debug level 3.
>    7 Return to level 2.
>    8 Return to debug level 2.
>    9 Return to level 1.
>   10 Return to debug level 1.
>   11 Return to level 0.
>   12 Return to top loop level 0.
>
> Type :b for backtrace, :c <option number> to proceed,  or :? for other
> options

1. Start a fresh lisp.
2. Type (describe '+)
3. Type (describe '+)
4. Become enlightened.

Duane
From: karsten
Subject: Re: Why this doesn't work?
Date: 
Message-ID: <ea087e7b-1e18-4d58-ad8f-d6e5bcf7e0d5@p13g2000yqc.googlegroups.com>
On Feb 12, 8:37 am, Slobodan Blazeski <·················@gmail.com>
wrote:
> I assign the function to symbol-value but sometimes works sometimes
> doesn't. What I don't understand?
> (setq plus #'+)
> #<Function + 20A6521A>
>
> (mapcar plus '(1 2) '( 3 4))
> (4 6)
>
> (setq + #'+)
> #<Function + 20A6521A>
> CL-USER 14 : 5 > (mapcar plus '(1 2) '( 3 4))
> (4 6)
>
> (mapcar + '(1 2) '( 3 4))
> Error: Argument to apply/funcall is not a function: (MAPCAR PLUS
> (QUOTE (1 2)) (QUOTE (3 4))).
>    1 (abort) Return to level 5.
>    2 Return to debug level 5.

Bad choice of variable-name, + has a special semantics, see
http://www.lispworks.com/documentation/HyperSpec/Body/v_pl_plp.htm.

With sbcl one even gets a nicer error message:
The value (SETQ + #'+) is not of type (OR FUNCTION SYMBOL).

salu2

Karsten
From: Slobodan Blazeski
Subject: Re: Why this doesn't work?
Date: 
Message-ID: <182c4e7b-2421-4c83-8e82-96e0ef09b8f0@j8g2000yql.googlegroups.com>
On Feb 12, 9:19 am, karsten <·············@gmail.com> wrote:
> On Feb 12, 8:37 am, Slobodan Blazeski <·················@gmail.com>
> wrote:
>
>
>
>
>
> > I assign the function to symbol-value but sometimes works sometimes
> > doesn't. What I don't understand?
> > (setq plus #'+)
> > #<Function + 20A6521A>
>
> > (mapcar plus '(1 2) '( 3 4))
> > (4 6)
>
> > (setq + #'+)
> > #<Function + 20A6521A>
> > CL-USER 14 : 5 > (mapcar plus '(1 2) '( 3 4))
> > (4 6)
>
> > (mapcar + '(1 2) '( 3 4))
> > Error: Argument to apply/funcall is not a function: (MAPCAR PLUS
> > (QUOTE (1 2)) (QUOTE (3 4))).
> >    1 (abort) Return to level 5.
> >    2 Return to debug level 5.
>
> Bad choice of variable-name, + has a special semantics, seehttp://www.lispworks.com/documentation/HyperSpec/Body/v_pl_plp.htm.
>
> With sbcl one even gets a nicer error message:
> The value (SETQ + #'+) is not of type (OR FUNCTION SYMBOL).
>
> salu2
>
> Karsten
Thanks.

bobi