>>>>> "JNP" == Joshua N Pritikin <[EMAIL PROTECTED]> writes:
>> then i am curious, what and how do you store the info for a watcher? if
>> not in the hash of $watcher, then what? a pseudohash? or closures?
JNP> Magic:
JNP> sv_bless(ref, stash);
JNP> mgp = &SvMAGIC(temple);
JNP> while ((mg = *mgp))
JNP> mgp = &mg->mg_moremagic;
JNP> New(0, mg, 1, MAGIC);
JNP> Zero(mg, 1, MAGIC);
oooohhh, deep black magic.
JNP> The real data is not accessible from perl, except by methods.
JNP> You can also add methods with a prefix. For example,
>>
JNP> package Event::Watcher;
JNP> sub uri_data { ... }
>>
>> is that documented?
JNP> Not yet.
>> what prefix is allowed (any string)? i assume the
>> prefix is to avoid method name collisions. this is not cool OO coding
>> either IMO. i will write damian conway to see what he thinks about that
>> idea.
JNP> I think it's cool OO once it's documented. Perl's OO is pretty strange.
maybe. i will run it by damian to get his take anyhow. at least document
that so i feel better about it. but the direct access of the hash is not
cool. adding methods via a public and documented path is sorta ok. but
it still means that my new methods KNOWS the internals of the watcher in
that it will access the hash part (even if it is not used). so adding a
data method to your code would seem to me to be the cleanest
approach. one simple method and i can store all the data i want any way
i want it and never worry about implementation or naming issues.
please?????
:-)
in my c based event loops, i always had a data pointer in the events. it
made the api very simple and no internal knowledge was ever needed. but
that assumed 2 separate 'objects', the internal event and the external
data. with event.pm in OO form, you can't do that without a data method
as event uses my object for a callback and i callback another higher
object so i have to encapsulate them all.
this gets confusing in any case. i need a separate OO layer above
event.pm for the api i want so the objects i pass to cb =>[] have to be
mine and not the user's. so i need encapsulation even if you gave me the
data method.
thanx,
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