Eduardo Cavazos <[email protected]> writes:

The (glamour mouse) library has a few macros for working with the mouse:

    http://github.com/dharmatech/agave/raw/master/glamour/mouse.sls

These work great in a script where everything is defined at the "top
level". However, notice something; each macro expands into definitions
followed by non-definition statements. This means that if you want to
setup a demo inside of a scope (this easily comes up when you want
multiple windows running in the same Scheme instance) then you have to
do things like this:

[code snipped]

I.e. put each macro at the top of a new 'let' body.

I thought it would be neat to have macros which work and look nice
when used at the top level as well as inside 'define' and 'let'
bodies. But perhaps the way glut is designed prevents a
straightforward path to this.

Suggestions welcome!

Andreas Rottmann wrote:

What I do in these cases (I have run into this problem several times as
well), is make the macro expand into a series of definitions only, using
a dummy definition around the expresssions, like this:

(define dummy
  (begin
    (some-expr)
    (and-another)
    'dummy-val))

Because this is ugly, I use define-values to hide (some of) the
boilerplate, making it somewhat nicer:

(define-values ()
  (some-expr)
  (and-another))

That will expand to pretty much the previous example; at least with the
define-values implementation I'm using (which ignores the values
returned by the body if the list of defined identifiers is empty).

Aha... thank you!

Ed

Reply via email to