Hi all,
I'm puzzling a little over the arguments that a function used as a
widget is supposed to be prepared to accept. In the documentation and
examples I see such functions having a &rest parameter which is then
ignored. But I don't see anywhere in the docs anything that says what
the arguments could be, and all the relevant code (e.g., RENDER-WIDGET-
BODY methods) just seems to pass along arguments as they have been
received -- except for the call to RENDER-WIDGET within RENDER-DIRTY-
WIDGETS, which doesn't pass any.
This comes up because I am finding it would be convenient in various
places if a function widget could be passed its parent (e.g., so it
could call ANSWER on it). Otherwise the function has to be closed
over a variable holding the parent, which is certainly doable but
clutters the code a bit. For example, I get code like this:
(let ((w (make-instance 'widget)))
(setf (widget-children w)
(list (lambda (&rest args)
(with-html
(:p (render-link (lambda (&rest args)
(answer w))
"Log Out"))))))
w)
which is not nearly as clean as just (make-widget (list
(lambda ...))) .
I suppose the first question is, am I missing some already-provided
way to deal with this?
But supposing I'm not, then the question is, if I modify RENDER-WIDGET-
CHILDREN on WIDGET to pass the parent to the children -- say, by doing
(setf (getf args :parent) obj) before doing anything else -- am I
going to break anything? Does this seem like a reasonable thing to
do?
[Alas, it can't be done quite that easily -- (SETF GETF) is
unfortunately allowed to bash the plist passed it, and since &rest
parameters are allowed to share structure with the last argument to
APPLY, it appears there's a risk of a nested call to RENDER-WIDGET-
CHILDREN bashing the list in use by an outer call. But that conveys
the idea anyway.]
-- Scott
--
You received this message because you are subscribed to the Google Groups
"weblocks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/weblocks?hl=en.