>>>>> "JNP" == Joshua N Pritikin <[EMAIL PROTECTED]> writes:
JNP> Hm. I'm not sure. Certainly, it is reasonable to clear the fd like:
>>
JNP> $io_watcher->fd(undef);
>>
>> would that stop/cancel the watcher? what effect does it have other than
>> to clear the attribute?
JNP> IIRC, it is like calling $io->stop.
but if the fd is erased, could you restart it?
JNP> Are you saying that you want a warning if that happens in the
JNP> constructor?
>>
>> i think that is what happened so it looks like a good place for a
>> warning. makes no sense to do an io event on an undef fd.
JNP> Presently, all attributes are available via the constructor in
JNP> the same manner as the function interface. I'm not sure I want
JNP> to break the symmetry.
i don't think that applies. a constructor can and should check things
that a attribute method doesn't have to. creating an io event with no or
an undef fd should be a fatal error or warning. undefing it later via the
attribute should be a cancel and not a stop as there is no fd to watch.
on a similar note, i create write events and immediately stop them. this
is so all you have to do later when you have data to write is to start
them. what about adding a stop attribute to the constructor so i don't
have to make the extra call to stop. it is a common idea as write events
will be triggered immediately (in most cases on sockets) after creation
which is not always what you want. it is not clear from the docs which
attributes are methods only and which are constructor only and which are
both. that could be marked in the docs as well. you say most can be done
both ways but as with the fd one, it has slightly different behavior in
the constructor vs. the method (constructor blows up on undef fd, method
does a stop). these differences need to be documented.
as i get into this more and more i will be pushed into a rewrite of the
event.pm docs. kick me on this. it is definitely something i have on the
medium term schedule.
uri
--
Uri Guttman --------- [EMAIL PROTECTED] ---------- http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page ----------- http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net ---------- http://www.northernlight.com