Per Bojsen <[EMAIL PROTECTED]> writes:

> I was wondering if it would be possible to add an extra argument to
> the gnc:choose-item-from-list-dialog function that would be parsed
> straight to the thunks?  That way the caller of
> gnc:choose-item-from-list-dialog could pass arbitrary user
> information to the thunks without relying on global variables.

(Aside: there are a couple of C-side garbage collection issues I just
 discovered that I need to check in to before releasing the code that
 might impact what I'm about to say, but chances are good that this
 answer will still hold when I'm done.)

No need.  This is scheme, you can just capture a closure containing
the data you need.  (Though if people really want an argument, I
suppose I could consider adding one, or just creating a wrapper
function around my existing function that creates the appropriate
anonomous closures).

For example (psuedo-code):

  (register-callback-with-data widget some-function some-data)

is completely equivalent to

  (register-callback widget (lambda () (some-function some-data)))

except that with the latter, you can capture as much data as you want,
you don't have to create data structures to hold all the parameters
you need to pass to the callback and then unpack them in the callback.
i.e. you could also say:

  (register-callback widget (lambda ()
                              (some-function some-data)
                              (some-other-function some-other-data)))

With the "one data parameter" approach that you were suggesting, you'd
have to wrap up some-data and some-other-data somehow and then unpack
them in the callback.

-- 
Rob Browning <[EMAIL PROTECTED]> PGP=E80E0D04F521A094 532B97F5D64E3930
----- %< -------------------------------------------- >% ------
The GnuCash / X-Accountant Mailing List
To unsubscribe, send mail to [EMAIL PROTECTED] and
put "unsubscribe gnucash-devel [EMAIL PROTECTED]" in the body

Reply via email to