On 16 Sep 2000 08:08:05 -0000, Perl6 RFC Librarian wrote:

>If some special action handler needs to be registered, this should be
>done not by using a special name, but by a pragma.
>
>  use tie STORE => sub { ... };
>
>not
>
>  sub STORE { ... }

Hmmm... this sounds like a less efficient approach. I think it's less
clean, too: we'd be moving away from pure integrated language, back into
a hack. By this, I mean that the proposed substitute can be probably be
implemented in a module, without special provisions from the language.

This post did trigger a few other ideas:

 * supposing UPPERCASE subs are still used for such speial functions
(callbacks, event handlers), Perl should warn if you use a sub with an
all uppercase name that isn't a registered callback. For example, in
using a tied filehandle, I made a sub CLOSE, and I wondered why it was
never called. It turned out that CLOSE wasn't a callback at the time...
(It is now.)

 * How about another type of sub, one that isn't called a "sub"? For
example, a "callback?

        callback STORE {
           ...
        }

At compile time, Perl could check out existence of event handlers (see
my first point) and maybe sub prototypes. If these don't match: poof.

-- 
        Bart.

Reply via email to