Re: Gtk2::TreeModel - foreach

On Nov 19, 2009, at 4:15 PM, Jeff Hallock wrote:

-----Original Message-----
From: gtk-perl-list-bounces gnome org [mailto:gtk-perl-list- bounces gnome org] On Behalf Of Zettai Muri
Sent: Thursday, November 19, 2009 3:56 PM
To: Martin Schlemmer; gtk-perl-list gnome org
Subject: Re: Gtk2::TreeModel - foreach

Where does the $user_data (scalar) part of the method come into play?
Is it possible to get an extended example that shows how this is used?

Is this data within the ListStore or some other data passed to the method? How does the method act on this data?

Again thanks for the help.

If you supply $user_data - then you it will be passed in as the last argument to the ForEach function.

If you're thinking, "but i can just use a closure for that", then you're already thinking perlishly.

The C api has user data pointers all over the place, because C doesn't have closures. In perl, you get the option of using a closure or passing different parameters to a single function. You'd choose to use the single function plus user data instead of a closure in a situation in which the closure would introduce a reference cycle. Pretty much any other time, you'd use a closure.

I can't believe i'm having to arbitrate who gets to have what dress on whose monkey.
  -- Me, exasperated at the ridiculousness of parenthood.

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]