[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.lisp

Strange Compilation failed.

james

9/30/2015 8:48:00 AM

Here is my code which will get compilation error

(defun by_with_wraper (n_wraper exchange)
(let ((var (floor n_wraper exchange))
(n_choco 0))
(incf n_choco (nth-value 0 var))
(if (> n_choco 0)
(by_with_wraper (+ n_choco (nth-value 1 var)) exchange)
(return-from by_with_wraper n_choco))))


test.lisp:212:25:
note: deleting unreachable code
warning:
Derived type of #:KEEPER2 is
(VALUES NULL &OPTIONAL),
conflicting with its asserted type
NUMBER.
See also:
SBCL Manual, Handling of Types [:node]

Compilation failed.

But after I change to the following code " (+ n_choco (nth-value 1 var)) ---> (+ n_choco (nth-value 0 var))". Every thing is ok. Any idea about this error?

(defun by_with_wraper (n_wraper exchange)
(let ((var (floor n_wraper exchange))
(n_choco 0))
(incf n_choco (nth-value 0 var))
(if (> n_choco 0)
(by_with_wraper (+ n_choco (nth-value 0 var)) exchange); Here is the difference
(return-from by_with_wraper n_choco))))
6 Answers

gengyangcai

9/30/2015 9:00:00 AM

0

Strangely enough, when i ran your original piece of code, it worked for me :


CL-USER 1 > (defun by_with_wraper (n_wraper exchange)
(let ((var (floor n_wraper exchange))
(n_choco 0))
(incf n_choco (nth-value 0 var))
(if (> n_choco 0)
(by_with_wraper (+ n_choco (nth-value 1 var)) exchange)
(return-from by_with_wraper n_choco))))
BY_WITH_WRAPER




On Wednesday, September 30, 2015 at 4:47:53 PM UTC+8, james wrote:
> Here is my code which will get compilation error
>
> (defun by_with_wraper (n_wraper exchange)
> (let ((var (floor n_wraper exchange))
> (n_choco 0))
> (incf n_choco (nth-value 0 var))
> (if (> n_choco 0)
> (by_with_wraper (+ n_choco (nth-value 1 var)) exchange)
> (return-from by_with_wraper n_choco))))
>
>
> test.lisp:212:25:
> note: deleting unreachable code
> warning:
> Derived type of #:KEEPER2 is
> (VALUES NULL &OPTIONAL),
> conflicting with its asserted type
> NUMBER.
> See also:
> SBCL Manual, Handling of Types [:node]
>
> Compilation failed.
>
> But after I change to the following code " (+ n_choco (nth-value 1 var)) ---> (+ n_choco (nth-value 0 var))". Every thing is ok. Any idea about this error?
>
> (defun by_with_wraper (n_wraper exchange)
> (let ((var (floor n_wraper exchange))
> (n_choco 0))
> (incf n_choco (nth-value 0 var))
> (if (> n_choco 0)
> (by_with_wraper (+ n_choco (nth-value 0 var)) exchange); Here is the difference
> (return-from by_with_wraper n_choco))))

Pascal J. Bourguignon

9/30/2015 9:20:00 AM

0

james <dinglei2008@gmail.com> writes:

> Here is my code which will get compilation error
> [â?¦]
> Any idea about this error?

Multiple values are not first class objects. You cannot bind them to
variables.


--
__Pascal Bourguignon__ http://www.informat...
â??The factory of the future will have only two employees, a man and a
dog. The man will be there to feed the dog. The dog will be there to
keep the man from touching the equipment.� -- Carl Bass CEO Autodesk

james

9/30/2015 9:21:00 AM

0

On Wednesday, September 30, 2015 at 4:59:58 PM UTC+8, CAI GENGYANG wrote:
> Strangely enough, when i ran your original piece of code, it worked for me :
>
>
> CL-USER 1 > (defun by_with_wraper (n_wraper exchange)
> (let ((var (floor n_wraper exchange))
> (n_choco 0))
> (incf n_choco (nth-value 0 var))
> (if (> n_choco 0)
> (by_with_wraper (+ n_choco (nth-value 1 var)) exchange)
> (return-from by_with_wraper n_choco))))
> BY_WITH_WRAPER
>
>
>
>
> On Wednesday, September 30, 2015 at 4:47:53 PM UTC+8, james wrote:
> > Here is my code which will get compilation error
> >
> > (defun by_with_wraper (n_wraper exchange)
> > (let ((var (floor n_wraper exchange))
> > (n_choco 0))
> > (incf n_choco (nth-value 0 var))
> > (if (> n_choco 0)
> > (by_with_wraper (+ n_choco (nth-value 1 var)) exchange)
> > (return-from by_with_wraper n_choco))))
> >
> >
> > test.lisp:212:25:
> > note: deleting unreachable code
> > warning:
> > Derived type of #:KEEPER2 is
> > (VALUES NULL &OPTIONAL),
> > conflicting with its asserted type
> > NUMBER.
> > See also:
> > SBCL Manual, Handling of Types [:node]
> >
> > Compilation failed.
> >
> > But after I change to the following code " (+ n_choco (nth-value 1 var)) ---> (+ n_choco (nth-value 0 var))". Every thing is ok. Any idea about this error?
> >
> > (defun by_with_wraper (n_wraper exchange)
> > (let ((var (floor n_wraper exchange))
> > (n_choco 0))
> > (incf n_choco (nth-value 0 var))
> > (if (> n_choco 0)
> > (by_with_wraper (+ n_choco (nth-value 0 var)) exchange); Here is the difference
> > (return-from by_with_wraper n_choco))))

I think i got the reason. By doing this (var (floor n_wraper exchange),var is a integer but not a values. I am using sbcl.

james

9/30/2015 9:28:00 AM

0

On Wednesday, September 30, 2015 at 5:19:55 PM UTC+8, informatimago wrote:
> james <dinglei2008@gmail.com> writes:
>
> > Here is my code which will get compilation error
> > [...]
> > Any idea about this error?
>
> Multiple values are not first class objects. You cannot bind them to
> variables.
>
>
> --
> __Pascal Bourguignon__ http://www.informat...
> "The factory of the future will have only two employees, a man and a
> dog. The man will be there to feed the dog. The dog will be there to
> keep the man from touching the equipment." -- Carl Bass CEO Autodesk

Thanks, what the definition of "first class objects" and what its member?

Pascal J. Bourguignon

9/30/2015 9:51:00 AM

0

james <dinglei2008@gmail.com> writes:

> On Wednesday, September 30, 2015 at 5:19:55 PM UTC+8, informatimago wrote:
>> james <dinglei2008@gmail.com> writes:
>>
>> > Here is my code which will get compilation error
>> > [...]
>> > Any idea about this error?
>>
>> Multiple values are not first class objects. You cannot bind them to
>> variables.
>
> Thanks, what the definition of "first class objects" and what its member?

https://en.wiktionary.org/wiki/first-cl...

--
__Pascal Bourguignon__ http://www.informat...
â??The factory of the future will have only two employees, a man and a
dog. The man will be there to feed the dog. The dog will be there to
keep the man from touching the equipment.� -- Carl Bass CEO Autodesk

james

9/30/2015 9:53:00 AM

0

On Wednesday, September 30, 2015 at 5:51:14 PM UTC+8, informatimago wrote:
> james <dinglei2008@gmail.com> writes:
>
> > On Wednesday, September 30, 2015 at 5:19:55 PM UTC+8, informatimago wrote:
> >> james <dinglei2008@gmail.com> writes:
> >>
> >> > Here is my code which will get compilation error
> >> > [...]
> >> > Any idea about this error?
> >>
> >> Multiple values are not first class objects. You cannot bind them to
> >> variables.
> >
> > Thanks, what the definition of "first class objects" and what its member?
>
> https://en.wiktionary.org/wiki/first-cl...
>
> --
> __Pascal Bourguignon__ http://www.informat...
> "The factory of the future will have only two employees, a man and a
> dog. The man will be there to feed the dog. The dog will be there to
> keep the man from touching the equipment." -- Carl Bass CEO Autodesk

Thanks for point this.