From: Kazimir Majorinc on 25 Mar 2010 11:58 Pascal, your example: (let ((x 1)) (macrolet ((foo () 'x)) (let ((x 2)) (incf (foo))))) ; ==> 3 -- Replaced with (let ((x 1)) (macrolet-with-gensyms ((foo () 'x)) (let ((x 2)) (incf (foo))))) === if expanded to ==> (let((x 1)) (let ((G3197 x)) (macrolet((foo () 'G3197)) (first (list (let ((x 2)) (incf (foo))))) (setf x G3197)))) ;==>2 It works, doesn't it? And outer binding x is also updated with (setf x ...).
From: Pascal Costanza on 25 Mar 2010 14:42 On 25/03/2010 16:58, Kazimir Majorinc wrote: > > Pascal, your example: > > (let ((x 1)) > (macrolet ((foo () 'x)) > (let ((x 2)) > (incf (foo))))) ; ==> 3 > > -- > Replaced with > > (let ((x 1)) > (macrolet-with-gensyms ((foo () 'x)) > (let ((x 2)) > (incf (foo))))) > > === if expanded to ==> > > (let((x 1)) > (let ((G3197 x)) > (macrolet((foo () 'G3197)) > (first (list > (let ((x 2)) > (incf (foo))))) > > (setf x G3197)))) ;==>2 What does the following result in? (let ((x 1)) (macrolet ((foo () 'x)) (let ((x 47)) (incf (foo))) (+ x x))) How do I make sure that it has the same result as the following, but without renaming any of the x bindings? (let ((x 1)) (macrolet ((foo () 'x)) (let ((y 47)) (incf (foo))) (+ x x))) Pascal -- My website: http://p-cos.net Common Lisp Document Repository: http://cdr.eurolisp.org Closer to MOP & ContextL: http://common-lisp.net/project/closer/
From: Hugh Aguilar on 25 Mar 2010 17:51 On Mar 24, 9:00 pm, Eli Barzilay <e...(a)barzilay.org> wrote: > Hugh Aguilar <hughaguila...(a)yahoo.com> writes: > > My ultimate goal is still CLOS. I've had AMOP on my bookshelf for > > quite a few years. Every time I walk past I think: "I should read > > that book before I die." [...] > > Here's an alternative suggestion which might be more suitable if > you're comfortable with code: start with tiny-clos (it's easy to > find), and just learn how it works. IMO, AMOP does a very good job in > making you appreciate the MOP, but following an implementation is > doing that even more effectively. > > Note that it is in Scheme, but doesn't use anything sophisticated, and > would probably be effective for just reading through, even if you > don't try to actually run it. Also note that it's much simpler than > CLOS, but has all the clever ideas in -- so if you follow that, then > understanding CLOS would be significantly easier. I like the idea of starting out with simple implementations and then graduating to more complicated feature-rich implementations only when I am ready --- and only if the simple implementation has proven inadequate. I'm pretty much sold on PLT Scheme as the way to learn this stuff. Slobodan has convinced me that this won't "mess me up," so there will be plenty of time to learn CL later on if I feel inspired to expand my horizons. The first thing I will do is port my symtab program from Forth; it is pretty short and simple. I will post that on comp.lang.scheme when it is ready so that I can get some feedback on style. Is it true that posting PLT Scheme code here on comp.lang.lisp would be frowned upon, as this forum is mostly for CL? BTW, do any of you guys use Erlang or LFE? Do these languages get supported on this forum?
From: Eli Barzilay on 25 Mar 2010 20:48 Hugh Aguilar <hughaguilar96(a)yahoo.com> writes: > The first thing I will do is port my symtab program from Forth; it > is pretty short and simple. I will post that on comp.lang.scheme > when it is ready so that I can get some feedback on style. Is it > true that posting PLT Scheme code here on comp.lang.lisp would be > frowned upon, as this forum is mostly for CL? The PLT mailing list is the best place for such posts. http://plt-scheme.org/maillist -- ((lambda (x) (x x)) (lambda (x) (x x))) Eli Barzilay: http://barzilay.org/ Maze is Life!
From: Eli Barzilay on 25 Mar 2010 20:57
Kazimir Majorinc <email(a)false.false> writes: > On 14.3.2010 20:11, Eli Barzilay wrote: > > Excellent post, Eli. However, I'm interested > in this part: > >> One point that can help getting some enlightenment is that hygiene >> is a crucial aspect of these kind of language games -- and I'm >> talking about both sides of it: both the part that you solve in CL >> with a gensym, and the part that cannot be solved by a macro (where >> you want to avoid names in the result of macros from being captured >> by names that happen to be bound in the call site). The latter is >> usually dismissed by CLers as not being too important, yet it is >> IME even more important than the first one when you're dealing with >> creating a new language. > > It is not obvious to me that this second part of hygiene, i.e. > macros that use the values of the symbols from macro definition > environment, not environment of use, is impossible in CL macro > systems without some package or namespaces. One way that makes it possible to a limited extent is using the package system. (And I've already mentioned some of the way in which this is limited.) Another option is when you can do a global transformation of the complete code, but that's a much less expressive (and less convenient) solution. (Macros draw their power from being local code transformations.) > Why do you claim that, Eli? If answer is not simple, do you have > any reference with more detailed discussion? See the DEFUN tutorial I pointed to for some examples. -- ((lambda (x) (x x)) (lambda (x) (x x))) Eli Barzilay: http://barzilay.org/ Maze is Life! |