[Openmcl-devel] pref with vriable field name

Taoufik Dachraoui taoufik at mazeboard.com
Mon Jan 25 10:40:14 UTC 2010


need to intern to :keyword

(defmacro xpref (thing type slotname)
 `(pref ,thing ,(intern (format nil "~A.~A" (symbol-name type) slotname)
:keyword)))

Taoufik

On Mon, Jan 25, 2010 at 10:37 AM, Taoufik Dachraoui
<taoufik at mazeboard.com>wrote:

> I tried this but it did not work cause the type is prefixed with a column
> and when interning
> it returns a symbol prefixed by a backslash
>
> > Error: Unknown foreign type: :\'<XE>XPOSE<E>VENT
> > While executing: CCL::%PARSE-FOREIGN-TYPE, in process listener(1).
> > Type :GO to continue, :POP to abort, :R for a list of available restarts.
> > If continued: Skip loading init file.
>
> Taoufik
>
> On Mon, Jan 25, 2010 at 10:30 AM, Ron Garret <ron at flownet.com> wrote:
>
>> Try something like:
>>
>> (defmacro xpref (thing type slotname)
>>  `(pref ,thing ,(intern (format nil "~A.~A" type slotname))))
>>
>> rg
>>
>> On Jan 25, 2010, at 12:25 AM, Taoufik Dachraoui wrote:
>>
>> > Hi
>> >
>> > I have the following code:
>> >
>> > (defmacro defonevent (onevent eventtype xstruct)
>> >   `(defmacro ,onevent (&rest body)
>> >      `(progn
>> >       (if (null (gethash (window *context*) %event-handlers%))
>> >           (setf (gethash (window *context*) %event-handlers%)
>> (make-hash-table)))
>> >       (setf (gethash ,',eventtype (gethash (window *context*)
>> %event-handlers%))
>> >             #'(lambda (event)
>> >                 (macrolet ((this (var) `(xpref event ',',',xstruct
>> ,var)))
>> >                   (this window) ; to avoid the warning if the event is
>> not used in the body
>> >                   , at body))))))
>> >
>> > (defonevent on-expose #$Expose :<XE>xpose<E>vent)
>> > (defonevent on-buttonpress #$ButtonPress :<XB>utton<E>vent)
>> > (defonevent on-buttonrelease #$ButtonRelease :<XB>utton<E>vent)
>> > (defonevent on-keypress #$KeyPress :<XK>ey<E>vent)
>> > (defonevent on-keyrelease #$KeyRelease :<XK>ey<E>vent)
>> > (defonevent on-clientmessage #$ClientMessage :<XC>lient<M>essage<E>vent)
>> > (defonevent on-mapnotify #$MappingNotify :<XM>ap<E>vent)
>> >
>> >
>> > ; usage
>> > (cell ....
>> >   (on-expose
>> >      (drawline 0 0 (this width) (this height)))
>> >   ...
>> >  )
>> >
>> >
>> > The issue is that I do not know how to implement xpref. The pref macro
>> takes an accessor of the form
>> > type.field but I need a macro that takes the type of the structure and
>> the field name separately.
>> >
>> > Thank you for your help
>> >
>> > Taoufik
>> > _______________________________________________
>> > Openmcl-devel mailing list
>> > Openmcl-devel at clozure.com
>> > http://clozure.com/mailman/listinfo/openmcl-devel
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.clozure.com/pipermail/openmcl-devel/attachments/20100125/364e1197/attachment.html>


More information about the Openmcl-devel mailing list