setq and read-line

General OpenLisp forum

setq and read-line

Postby marciot » Wed Jun 01, 2005 5:51 pm

It's been a long time since I've used LISP, so these may be a dumb questions, but when I first start OpenLisp, I expect to be able to set variables using setq, however, I always get "unbound-variable":

? (setq x 1)
** setq : unbound-variable : x

There are plenty of examples of setq in the OpenLisp manual, yet they don't seem to work for me.

I also can't get read-line to work:

? (read-line)
;; elapsed time = 0.000s, (0 gc).
=
?

Shouldn't it wait for me to type a line?

Are their any tutorials on doing simple things like this under OpenLisp? I really need a refresher course.

-- Marcio
marciot
 
Posts: 1
Joined: Wed Jun 01, 2005 5:43 pm
Location: Fort Collins, CO

Re: setq and read-line

Postby jullien » Thu Jun 02, 2005 7:10 am

marciot wrote:I expect to be able to set variables using setq, however, I always get "unbound-variable":

? (setq x 1)
** setq : unbound-variable : x


See the FAQ http://www.eligis.com/FAQ.html

ISLISP standard requires variable declaration at toplevel.

Code: Select all
? (defglobal x 100)
;; elapsed time =  0.000s, (0 gc).
= x
? (setq x 5)
;; elapsed time =  0.000s, (0 gc).
= 5
? (* x 2)
;; elapsed time =  0.000s, (0 gc).
= 10


marciot wrote:I also can't get read-line to work:

? (read-line)
;; elapsed time = 0.000s, (0 gc).
=


It works! You start reading a line just after the closing parenthesis.
Since there is nothing before '\n' you get an empty line.

Try:
Code: Select all
? (read-line)hello world
;; elapsed time =  0.000s, (0 gc).
= hello world
?


Are their any tutorials on doing simple things like this under OpenLisp? I really need a refresher course.


No, sorry.
jullien
Site Admin
 
Posts: 30
Joined: Fri Nov 12, 2004 12:29 am


Return to General discussion

Who is online

Users browsing this forum: No registered users and 3 guests

cron