develooper Front page | perl.perl5.porters | Postings from August 2001

Re: marking can() coderef as a method

Thread Previous | Thread Next
From:
Mark Mielke
Date:
August 24, 2001 00:03
Subject:
Re: marking can() coderef as a method
Message ID:
20010824030400.A6445@pcard12x.ca.nortel.com
On Thu, Aug 23, 2001 at 06:45:46PM -0400, "Michael G Schwern" wrote:
> On Thu, Aug 23, 2001 at 01:51:56PM -0400, Geoffrey Young wrote:
> >   I thought it might be genuinely useful to mark a coderef returned by
> > UNIVERSAL::can() as being a method so that XS routines can know whether to
> > use perl_call_method or perl_call_sv on it.  
>     use Text::Soundex;
>     my $func = UNIVERSAL::can('Text::Soundex', 'soundex');
>     print $func->("I assure you, this is not a method");
> even if called like this:
>     my $func = Text::Soundex->can('soundex');
> it's still not a method.

It is arguable that the '->can' should therefore fail.

Unfortunately, without enforcing ': method', such would be impossible
with perl, without having existing code break.

The easiest argument against, would be that can() is a read-only function,
and should therefore not have any 'side effects' at all.

I have a few qualms about perl's "a method is just a function that gets
invoked with a $this argument." One of these is that it isn't possible to
know (without documentation or referencing the code) how a static method
differs from a function. Compile time checks are usually useless.

I'm sure some would argue that this is actually 'flexibility', and that
it is somehow a good thing.

I just don't agree. :-)

mark

-- 
markm@nortelnetworks.com/mark@mielke.cc/markm@ncf.ca __________________________
.  .  _  ._  . .   .__    .  . ._. .__ .   . . .__  | SIR Tools          (7H12)
|\/| |_| |_| |/    |_     |\/|  |  |_  |   |/  |_   | Nortel Networks
|  | | | | \ | \   |__ .  |  | .|. |__ |__ | \ |__  | Ottawa, Ontario, Canada

  One ring to rule them all, one ring to find them, one ring to bring them all
                       and in the darkness bind them...

                           http://mark.mielke.cc/


Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About