From: Q
Subject: Simple question
Date: 
Message-ID: <1194011233.920524.211690@y42g2000hsy.googlegroups.com>
With the following:

(let ((x 1))
   (loop while (= x 1)
           as x = 3
           do (print "HI")))

I would like for "HI" to print out once, and then detect that x no
longer = 1 and exit.

I get the error
Error: In = of (NIL 1) arguments should be of type NUMBER.

Why can't the binding of x to 1 be seen inside the loop?  Or is
something else going on here?

Thanks!

From: Vebjorn Ljosa
Subject: Re: Simple question
Date: 
Message-ID: <1194012165.508565.25410@22g2000hsm.googlegroups.com>
On Nov 2, 9:47 am, Q <······@gmail.com> wrote:
> With the following:
>
> (let ((x 1))
>    (loop while (= x 1)
>            as x = 3
>            do (print "HI")))
>
> I would like for "HI" to print out once, and then detect that x no
> longer = 1 and exit.

Your loop is not syntactically correct because you have a main clause
followed by a variable clause.

What are you trying to do?  I would recommend reading an introduction
to loop.  Someone mentioned the chapter in Practical Common Lisp.  I
haven't seen it, but it's probably worth taking a look at.

Vebjorn
From: smallpond
Subject: Re: Simple question
Date: 
Message-ID: <1194013020.876181.90750@22g2000hsm.googlegroups.com>
Q wrote:
> With the following:
>
> (let ((x 1))
>    (loop while (= x 1)
>            as x = 3
>            do (print "HI")))
>
> I would like for "HI" to print out once, and then detect that x no
> longer = 1 and exit.
>
> I get the error
> Error: In = of (NIL 1) arguments should be of type NUMBER.
>
> Why can't the binding of x to 1 be seen inside the loop?  Or is
> something else going on here?
>
> Thanks!

"The iteration control clauses for, as, and repeat must precede any
other loop
clauses, except initially, with, and named, since they establish
variable bindings. "

In a bizarre twist of space-time, the X you use in the while statement
does
not exist yet because the following as clause creates it.
-S
From: Kamen TOMOV
Subject: Re: Simple question
Date: 
Message-ID: <uir4koi1o.fsf@cybuild.com>
On Fri, Nov 02 2007, Q wrote:

> With the following:
>
> (let ((x 1))
>    (loop while (= x 1)
>            as x = 3
>            do (print "HI")))
>
> I would like for "HI" to print out once, and then detect that x no
> longer = 1 and exit.
>
> I get the error
> Error: In = of (NIL 1) arguments should be of type NUMBER.
>
> Why can't the binding of x to 1 be seen inside the loop?  Or is
> something else going on here?

What seems to be happening (after binding x to 1 in the let form) is
that another binding of x to 3 is introduced in the loop form. The
main body is executed in the "while" clause and as it is false the
"do" clause gets never executed. In fact the "as" clause should
precede the main clause like that:

(let ((x 1))
   (loop as x = 3 
      while (= x 3)
      do (print "HI")))


-- 
�����