From: .Martin. on 18 Apr 2010 18:24 I'm running SBCL in slime. I'm doing my first steps in common lisp. Everything is fine, but for some reason I got the errors: CL-USER> (setf x 1) ; ; caught WARNING: ; undefined variable: X ; ; compilation unit finished ; Undefined variable: ; X ; caught 1 WARNING condition 1 Well, I know it's undefined - I'm trying to define it, aren't I? Am I missing something here? thank you -- regards ..Martin.
From: Barry Margolin on 18 Apr 2010 21:10 In article <878w8ks8jq.fsf(a)slack64.serverdot.org>, xtd8865(a)gmail.com (.Martin.) wrote: > I'm running SBCL in slime. I'm doing my first steps in common lisp. > Everything is fine, but for some reason I got the errors: > > > > CL-USER> (setf x 1) > > ; > > ; caught WARNING: > > ; undefined variable: X > > ; > > ; compilation unit finished > > ; Undefined variable: > > ; X > > ; caught 1 WARNING condition > > 1 > > > Well, I know it's undefined - I'm trying to define it, aren't I? > Am I missing something here? No, you're trying to assign it. To define it, use DEFVAR or DEFPARAMETER. -- Barry Margolin, barmar(a)alum.mit.edu Arlington, MA *** PLEASE post questions in newsgroups, not directly to me *** *** PLEASE don't copy me on replies, I'll read them in the group ***
From: .Martin. on 18 Apr 2010 21:30 Barry Margolin <barmar(a)alum.mit.edu> writes: > In article <878w8ks8jq.fsf(a)slack64.serverdot.org>, > xtd8865(a)gmail.com (.Martin.) wrote: > >> I'm running SBCL in slime. I'm doing my first steps in common lisp. >> Everything is fine, but for some reason I got the errors: >> >> >> >> CL-USER> (setf x 1) >> >> ; >> >> ; caught WARNING: >> >> ; undefined variable: X >> >> ; >> >> ; compilation unit finished >> >> ; Undefined variable: >> >> ; X >> >> ; caught 1 WARNING condition >> >> 1 >> >> >> Well, I know it's undefined - I'm trying to define it, aren't I? >> Am I missing something here? > > No, you're trying to assign it. To define it, use DEFVAR or > DEFPARAMETER. Thank you, it works. I though lips doesn't require defining symbols beforehand. It seems I was wrong. -- regards ..Martin.
From: His kennyness on 18 Apr 2010 23:41 ..Martin. wrote: > Barry Margolin <barmar(a)alum.mit.edu> writes: > >> In article <878w8ks8jq.fsf(a)slack64.serverdot.org>, >> xtd8865(a)gmail.com (.Martin.) wrote: >> >>> I'm running SBCL in slime. I'm doing my first steps in common lisp. >>> Everything is fine, but for some reason I got the errors: >>> >>> >>> >>> CL-USER> (setf x 1) >>> >>> ; >>> >>> ; caught WARNING: >>> >>> ; undefined variable: X >>> >>> ; >>> >>> ; compilation unit finished >>> >>> ; Undefined variable: >>> >>> ; X >>> >>> ; caught 1 WARNING condition >>> >>> 1 >>> >>> >>> Well, I know it's undefined - I'm trying to define it, aren't I? >>> Am I missing something here? >> No, you're trying to assign it. To define it, use DEFVAR or >> DEFPARAMETER. > > Thank you, it works. I though lips doesn't require defining symbols > beforehand. It seems I was wrong. > I see "warning" above. Where do you see "require"? I do not use SBCL/slime so I do not know if you were being stopped or warned, but if you were only being warned... right. Lisp will indeed warn you about undefined variables and also unused variables (they often come in pairs for the obvious reason). Useful indeed when they come in pairs. but yes, your observation is accurate: Lisp is not as wild and crazy as it is sometimes made out to be. Tho some Lisps are. An interpreted Lisp might fit that bill. kt
From: Rupert Swarbrick on 19 Apr 2010 04:37 xtd8865(a)gmail.com (.Martin.) writes: >> >> No, you're trying to assign it. To define it, use DEFVAR or >> DEFPARAMETER. > > Thank you, it works. I though lips doesn't require defining symbols > beforehand. It seems I was wrong. Well, it'll actually work in the slime repl despite the warning (although that should probably be a sign you're doing something wrong...) I'm not absolutely sure, but I think the logic is that if you don't declare (not define) symbols explicitly, it's not clear what lisp should make happen here. (defun run-me () (foo) (bar) (format t "~A~%" x)) (defun foo () (setf x 42) (format t "~A " x)) (defun bar () (format t "~A " x)) What should be printed? 42 42 42? Why should lisp guess that you want the undeclared x to be a global variable? Anyway, that seems to be the logic to me. Rupert
|
Next
|
Last
Pages: 1 2 3 Prev: linux .emacs file Next: "C-like" syntax for Lisp in less than 100 lines of code |