Add new comment

CLOS (for Common Lisp) has two forms with-slots and with-accessors that give you a similar expressiveness to a certain degree. With those forms, you can write this:

(defmethod area ((rect rect))
  (with-slots (top bottom right left) rect
     (* (- top bottom) (- right left))))

It's a bit tedious to have to reintroduce the variable names, but for longer methods this doesn't matter that much. On the plus side, you can introduce variable names for slots from several objects within the same method.

See http://www.lispworks.com/documentation/HyperSpec/Body/m_w_slts.htm and http://www.lispworks.com/documentation/HyperSpec/Body/m_w_acce.htm for more examples.

With the introduction of identifier macros in R6RS, it should be a piece of cake to introduce something similar for any object system in Scheme.

Filtered HTML

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
By submitting this form, you accept the Mollom privacy policy.