List Info

Thread: Re: Try OO semantics before throwing fatal error




Re: Try OO semantics before throwing fatal error
user name
2007-11-06 08:54:13
On Tue, Nov 06, 2007 at 06:25:51AM -0500, John Peacock
wrote:
} Linda Walsh (via RT) wrote:
} > Perl has runtime features that can turn what may seem
to be an undefined
} > function stub, and turn it into something useful via
Perl's AUTOLOAD
} > functionality that can catch, undefined subroutines
and load them at
} > runtime.  
} 
} There's nothing wrong with Perl's OO design.  It isn't
going to change (except
} in so much as what Perl6 does).  There is no point in
opening this
} bug/enhancement request, because you are [apparently] the
only person who thinks
} the current behavior is a problem.  Sorry to be harsh, but
you have been told
} repeatedly that the problem is your interpretation of how
Perl's object design
} works.  Perhaps you want the Java or C++ offices down the
hall...

Gosh, I dunno. I'm pretty sympathetic to the idea of method
resolution
silently skipping over undefined bodies. I've gotten the
impression
that the people responding to her are more out to brow-beat
Linda than
argue about anything technical.

I've supposed that the real reason several people continued
a thread
with her was that they were irritated at her tone.

PS: having to write defined(&{ ...->can(...) }) in
user code to ignore
undefined bodies sucks.

-- 
Josh
Re: Try OO semantics before throwing fatal error
user name
2007-11-06 09:07:16
On Tue, Nov 06, 2007 at 06:54:13AM -0800, Josh Jore wrote:
> On Tue, Nov 06, 2007 at 06:25:51AM -0500, John Peacock
wrote:
> } Linda Walsh (via RT) wrote:
> } > Perl has runtime features that can turn what may
seem to be an undefined
> } > function stub, and turn it into something useful
via Perl's AUTOLOAD
> } > functionality that can catch, undefined
subroutines and load them at
> } > runtime.  
> } 
> } There's nothing wrong with Perl's OO design.  It
isn't going to change (except
> } in so much as what Perl6 does).  There is no point in
opening this
> } bug/enhancement request, because you are [apparently]
the only person who thinks
> } the current behavior is a problem.  Sorry to be
harsh, but you have been told
> } repeatedly that the problem is your interpretation of
how Perl's object design
> } works.  Perhaps you want the Java or C++ offices down
the hall...
> 
> Gosh, I dunno. I'm pretty sympathetic to the idea of
method resolution
> silently skipping over undefined bodies. I've gotten
the impression
> that the people responding to her are more out to
brow-beat Linda than
> argue about anything technical.

I wouldn't want it to skip over undefined bodies in the
general case.
If you write (the equivalent of)

    sub Foo::bar;

then I'd expect it to try Foo::AUTOLOAD, and if that fails,
fail.
Otherwise it might silently hide a bug in Foo's AUTOLOAD

Else why would you stub subroutine bar in package Foo.

But for the case of taking a reference to an undefined
subroutine, I can see
why that might want to behave differently, and (implied)
internally be
represented by something different and distinguishable from
a stub.

As this is just for the case of methods, I'm not sure what
it really gains
over making method calls by name (which has been around,
IIRC, since 5.005),
but it would introduce both implementation and conceptual
complexity.

Nicholas Clark

Re: Try OO semantics before throwing fatal error
user name
2007-11-06 22:09:23
* Josh Jore <twistsgmail.com> [2007-11-06 15:55]:
> I'm pretty sympathetic to the idea of method
resolution
> silently skipping over undefined bodies.

MR responding to stubs was added for a reason. The only way
to
“fix” this behaviour without obliterating its original
and fully
intentional functionality is to skip stubs in absence of
AUTOLOAD, but respect them in its presence.

“You find a problem with a special case. You fix it by
special-
casing the special case. Now you have two problems.”

> I've gotten the impression that the people responding
to her
> are more out to brow-beat Linda than argue about
anything
> technical.

Linda wants to check whether a sub exists. Doing so by
taking a
reference to it is wrong – doing that creates a stub by
design.

The fact that this is causing method resolution to later
fail is
a red herring. Even if a special case was added to the
special
case in MR her code would *still* be creating extraneous
stubs.

Perl already has a perfectly servicable way to do what she
needs:
she can check the CODE slot in the relevant glob.

Why are we still having this discussion?

Regards,
-- 
Aristotle Pagaltzis // <http://plasmasturm.org/&g
t;

[1-3]

about | contact  Other archives ( Real Estate discussion Medical topics )