[plt-scheme] with-struct

From: Eli Barzilay (eli at barzilay.org)
Date: Wed Oct 21 22:12:39 EDT 2009

On Oct 21, Carl Eastlund wrote:
> On Wed, Oct 21, 2009 at 10:04 PM, Eli Barzilay <eli at barzilay.org> wrote:
> > Well, it should be easy to make that `with-foo' macro detect when the
> > value expression is really an identifier, and bind names like this:
> >
> >  (with-posn a
> >    (printf "<~s,~s>" a.x a.y))
> >
> > But that's getting too close to something like a real `.' infix syntax
> > (IIRC, Jens had implemented something like that).
> 
> So this macro is going to have different lexical binding structure
> if its argument -- an expression -- happens to be in the form of an
> identifier, than if it's any other expression?
> 
> I am wary of such voodoo.

Me too, but it shouldn't be too problematic, since you still get the
usual lexical scope.  For example, have it bind `a.x' and `a.y' and
make `x' and `y' aliases for them, so that the latter are always
getting the closest `with-*' values.

But in any case, it looks to me like there's too many variables so a
good design for this thing is going to be difficult.

-- 
          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:
                    http://barzilay.org/                   Maze is Life!


Posted on the users mailing list.