Matt Jadud wrote:
it is another thing entirely to have to remember
(with ([s (new Foo)]) ... (let ([x (some-method-on-s 5)] [y (not-a-method-on-s 3)]) ... (+ x y)))
and catch that 'some-method' is magically invoked on the object 's'. Then again, you might be syntactically limiting the nature of expressions allowable within the 'with' construct to side-effecting expressions on 's' that all are bound to methods of 's'; if not... yes, it might get confusing.
Hi,
Of course, Common Lisp has had similar such "with" clauses since CLOS was introduced in the late 80s but you do have to say what you are going to use ahead of time:
(+ (slot-value object 'slot1) (slot-value object 'slot2))
can be written using "with-slots" [1]:
(with-slots ((s1 slot1) (s2 slot2)) object
(+ s1 s2))or
(+ (accessor1 object) (accessor2 object))
can be written using "with-accessors" [2]:
(with-accessors ((a1 accessor1) (a2 accessor2)) object
(+ a1 a2))Moreover Common Lisp lets you write your own such macros using "symbol-macrolet" [3]. In general discussions about this level of syntax can always be informed by a working example in Common Lisp.
__Jason
[1] http://www.lisp.org/HyperSpec/Body/mac_with-slots.html
[2] http://www.lisp.org/HyperSpec/Body/mac_with-accessors.html
[3] http://www.lisp.org/HyperSpec/Body/speope_symbol-macrolet.html#symbol-macrolet
---------------------------------------------------------------------- PPIG Discuss List ([email protected]) Discuss admin: http://limitlessmail.net/mailman/listinfo/discuss Announce admin: http://limitlessmail.net/mailman/listinfo/announce PPIG Discuss archive: http://www.mail-archive.com/discuss%40ppig.org/
