LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 06-10-2013, 01:02 PM   #1
hydraMax
Member
 
Registered: Jul 2010
Location: Skynet
Distribution: Debian + Emacs
Posts: 467
Blog Entries: 60

Rep: Reputation: 51
Common Lisp: CLOS and with-slots


Hi. I'm a newbie to Common Lisp, and I'm using GNU Clisp. In working through a tutorial on CLOS, I set up a simple class and an instance:

Code:
(defclass rect () (l w))

(setf rect-a (make-instance 'rect))
One of the exercises challenged me to create a setter function, using with-slots. So, I wrote this:

Code:
(defun set-rect-values (rect l w)
  (with-slots ((l-old l) (w-old w))
	      rect
	      (setf 'l-old l)
	      (setf 'w-old w)))
But I get this error when trying to use it:

Code:
> (set-rect-values rect-a 2 2)

*** - SLOT-VALUE: The slot L of #<RECT #x0003348AC408> has no value
Please advise.
 
Old 06-10-2013, 08:59 PM   #2
ntubski
Senior Member
 
Registered: Nov 2005
Distribution: Debian, Arch
Posts: 3,774

Rep: Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081
Code:
(setf 'l-old l)
(setf l-old l)
Don't quote the first argument to setf.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] struggling with a function in Common Lisp sycamorex Programming 2 10-10-2011 04:04 AM
Common Lisp functions. zaxonus Programming 2 07-09-2010 04:30 PM
Programming Ideas in Common Lisp Trizon Programming 1 03-03-2008 02:07 PM
Common Lisp stand alone question Trizon Programming 5 05-23-2007 09:07 AM
Lisp(CLOS) vs c++ deadhead Programming 5 11-03-2003 11:50 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:06 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration