From: RPG
Subject: request for help with macro
Date: 
Message-ID: <1137441332.666453.222280@o13g2000cwo.googlegroups.com>
I'm trying to patch up some of the garnet stuff to compile with SBCL.
Use of the following macro definitions in compiled code seems to cause
SBCL to toss an error about being unable to save a compiled function in
a FASL file.  I assume this is because of the ,#'

(defmacro with-garnet-error-handling (context &body forms)
  "Executes forms in a protected environment where errors are handled
by garnet-error-handler, which creates a widget with options to abort,
debug and (if applicable) continue.

<context> should be a string describing user meaningful context in
which error occured. "
  `(handler-bind ((error ,#'(lambda (condition)
			      (garnet-error-handler context condition))))
     ,.forms))

(defmacro with-garnet-user-error-handling (context &body forms)
  "Executes forms in a protected environment where errors are handled
by garnet-user-error-handler, which creates a widget with options to
abort and (if applicable) continue (no debug option).

<context> should be a string describing user meaningful context in
which error occured."
  `(handler-bind ((error ,#'(lambda (condition)
			      (garnet-error-handler context condition
						    :allow-debugger nil))))
     ,.forms))

So my question is:  is there any reason why the macro needs to
*evaluate* this function, as opposed to just putting it in without the
comma?  The only thing I can think of is that this was intended to
avoid package problems, in which case package-qualifying the
garnet-error-handler should work, shouldn't it?

Thanks!

From: Barry Margolin
Subject: Re: request for help with macro
Date: 
Message-ID: <barmar-927249.21294416012006@comcast.dca.giganews.com>
In article <························@o13g2000cwo.googlegroups.com>,
 "RPG" <·········@gmail.com> wrote:

> I'm trying to patch up some of the garnet stuff to compile with SBCL.
> Use of the following macro definitions in compiled code seems to cause
> SBCL to toss an error about being unable to save a compiled function in
> a FASL file.  I assume this is because of the ,#'

Correct.

> 
> (defmacro with-garnet-error-handling (context &body forms)
>   "Executes forms in a protected environment where errors are handled
> by garnet-error-handler, which creates a widget with options to abort,
> debug and (if applicable) continue.
> 
> <context> should be a string describing user meaningful context in
> which error occured. "
>   `(handler-bind ((error ,#'(lambda (condition)
> 			      (garnet-error-handler context condition))))
>      ,.forms))
> 
> (defmacro with-garnet-user-error-handling (context &body forms)
>   "Executes forms in a protected environment where errors are handled
> by garnet-user-error-handler, which creates a widget with options to
> abort and (if applicable) continue (no debug option).
> 
> <context> should be a string describing user meaningful context in
> which error occured."
>   `(handler-bind ((error ,#'(lambda (condition)
> 			      (garnet-error-handler context condition
> 						    :allow-debugger nil))))
>      ,.forms))
> 
> So my question is:  is there any reason why the macro needs to
> *evaluate* this function, as opposed to just putting it in without the
> comma?  The only thing I can think of is that this was intended to
> avoid package problems, in which case package-qualifying the
> garnet-error-handler should work, shouldn't it?

It needs to get the value of CONTEXT that's passed to the macro.  The 
solution is to put the comma before CONTEXT, rather than before the 
entire lambda expression.

-- 
Barry Margolin, ······@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***
From: Thomas F. Burdick
Subject: Re: request for help with macro
Date: 
Message-ID: <xcvbqyb2h0x.fsf@conquest.OCF.Berkeley.EDU>
"RPG" <·········@gmail.com> writes:

> I'm trying to patch up some of the garnet stuff to compile with SBCL.
> Use of the following macro definitions in compiled code seems to cause
> SBCL to toss an error about being unable to save a compiled function in
> a FASL file.  I assume this is because of the ,#'

This looks highly suspicious to me.  Garnet is known to work with
CMUCL, which also won't dump constant functions.  So what gives?

-- 
           /|_     .-----------------------.                        
         ,'  .\  / | Free Mumia Abu-Jamal! |
     ,--'    _,'   | Abolish the racist    |
    /       /      | death penalty!        |
   (   -.  |       `-----------------------'
   |     ) |                               
  (`-.  '--.)                              
   `. )----'                               
From: RPG
Subject: Re: request for help with macro
Date: 
Message-ID: <1137530884.983802.96470@o13g2000cwo.googlegroups.com>
Thomas F. Burdick wrote:
> "RPG" <·········@gmail.com> writes:
>
> > I'm trying to patch up some of the garnet stuff to compile with SBCL.
> > Use of the following macro definitions in compiled code seems to cause
> > SBCL to toss an error about being unable to save a compiled function in
> > a FASL file.  I assume this is because of the ,#'
>
> This looks highly suspicious to me.  Garnet is known to work with
> CMUCL, which also won't dump constant functions.  So what gives?

I don't know; I wish I did.  This stuff is all heavily intertwined with
multiprocessing, which I have made (barely) work with sbcl threads (see
the Garnet version in Sourgeforge CVS).  Maybe some tweaking of
conditional compilation flags is keeping this code from being triggered
in CMUCL.

Paradoxically, since CMUCL was less fussy about compilation, I have
actually played with it less.  I can barely get the time to test this
on my primary platform, Allegro, much less the CMU CL variants.

Best,
R
From: Fred Gilham
Subject: Re: request for help with macro
Date: 
Message-ID: <u7zmlul5zl.fsf@snapdragon.csl.sri.com>
> > I'm trying to patch up some of the garnet stuff to compile with SBCL.
> > Use of the following macro definitions in compiled code seems to cause
> > SBCL to toss an error about being unable to save a compiled function in
> > a FASL file.  I assume this is because of the ,#'
> 
> This looks highly suspicious to me.  Garnet is known to work with
> CMUCL, which also won't dump constant functions.  So what gives?

This is probably my bad.  Get rid of the Garnet-Protected-Eval stuff
in the loader files and you will probably be OK.

Though I am able to compile this stuff with CMUCL....

Anyway the problem is that I incorporated some stuff that did the
widget-pop-up for errors (the idea being to make it possible to
protect the user from seeing anything but the GUI).  That code was in
the contrib directory and it seemed nice but I probably screwed it up
when I folded it in.  It seems to give trouble.  So it's best to just
get rid of it.

-- 
Fred Gilham                                        ······@csl.sri.com
Our original rights freed us from the state's power. Nowadays, most
alleged "rights" increase the state's power over us. -- Joseph Sobran
From: RPG
Subject: Re: request for help with macro
Date: 
Message-ID: <1137614187.196979.303550@g47g2000cwa.googlegroups.com>
Fred Gilham wrote:
> > > I'm trying to patch up some of the garnet stuff to compile with SBCL.
> > > Use of the following macro definitions in compiled code seems to cause
> > > SBCL to toss an error about being unable to save a compiled function in
> > > a FASL file.  I assume this is because of the ,#'
> >
> > This looks highly suspicious to me.  Garnet is known to work with
> > CMUCL, which also won't dump constant functions.  So what gives?
>
> This is probably my bad.  Get rid of the Garnet-Protected-Eval stuff
> in the loader files and you will probably be OK.
>
> Though I am able to compile this stuff with CMUCL....
>
> Anyway the problem is that I incorporated some stuff that did the
> widget-pop-up for errors (the idea being to make it possible to
> protect the user from seeing anything but the GUI).  That code was in
> the contrib directory and it seemed nice but I probably screwed it up
> when I folded it in.  It seems to give trouble.  So it's best to just
> get rid of it.
OK, for the moment, I have modified the garnet-loader to NOT load
protected-eval by default.
Thanks for the note, Fred.