Marc Lehmann, el 22 de enero a las 12:40 me escribiste: > On Mon, Jan 21, 2008 at 11:25:52PM -0200, Leandro Lucarella <[EMAIL > PROTECTED]> wrote: > > Well, the compiler complained about changing the meaning of loop in the > > context of the watcher's base class, but adding the namespace to the type > > when declaring the loop variable did the trick. > > > > I'll commit this patch unless you have something against it: > > http://git.llucax.com.ar/?p=software/libev.git;a=commitdiff;h=a11114f6c6a06077bcd9e208c064ebed9e577f8c > > > > (I added operator () as an alias to run ()). > > Looks fine, but please do not use EV_THROW for the exception specification > (I changed thta in CVS already), but instead use plain throw (). > > The main drawback of using exceptions is using stdexcept, not specifying > what a function throws.
I know, I just added EV_THROW in case some weird ol' compiler doesn't support eceptions at all. But I guess there are not such things anymore. > > > I don't find anything natural at all at calling as do-called "init" method > > > in C++, "shouldn't this be done by the constructor?" :) > > > > Yes, but you didn't like the explicit default_loop instantiation =) > > And the loop has to be initialized somewhere... > > Yes, when first accessed, e.g. here: > > ev::io myw(ev::default_loop); > > would be fine. My proposal does just that without static initialisation. What if I want to initialize it with some arguments? One of my experiments was: static struct { loop operator () (unsigned int flags = AUTO) throw (bad_loop) { return ev_default_loop (flags); } operator loop () () throw (bad_loop) { return ev_default_loop (0); } // No operator -> since we have to return a loop* and we don't // have any. } default_loop; So you can use it like: ev::loop loop = ev::default_loop (ev::NOFLAGS); //... ev::io myw(ev::default_loop); But I think it's a little obscure and the only gain is avoid typing "()", which will be only necessary once in most cases (because you'll use the loop only once in that scope or because you'll store it in a local loop variable). -- Leandro Lucarella (luca) | Blog colectivo: http://www.mazziblog.com.ar/blog/ ---------------------------------------------------------------------------- GPG Key: 5F5A8D05 (F8CD F9A7 BF00 5431 4145 104C 949E BFB6 5F5A 8D05) ---------------------------------------------------------------------------- No es malo que en la condición humana exista la mentira. Miente el púber si quiere ponerla. -- Ricardo Vaporeso. Madrid, 1921. _______________________________________________ libev mailing list libev@lists.schmorp.de http://lists.schmorp.de/cgi-bin/mailman/listinfo/libev