develooper Front page | perl.perl5.porters | Postings from May 2012

Re: Objects without stashes?

Thread Previous | Thread Next
From:
Eric Brine
Date:
May 25, 2012 10:40
Subject:
Re: Objects without stashes?
Message ID:
CALJW-qFo7y-J2CNMEnCj8hZ3jDpLEBHXgOa13GO44=80Ggm73A@mail.gmail.com
On Fri, May 25, 2012 at 10:47 AM, Leon Timmermans <fawaka@gmail.com> wrote:

> > An object is different from any other data type in Perl in one and only
> one way: you may dereference it using not merely string or numeric
> subscripts as with simple arrays and hashes, but with named subroutine
> calls. In a word, with methods.
>
> There is nothing, absolutely nothing, about this that requires stashes
> (or for that matter, there's nothing that requires packages/classes
> either). What if we simply added a vtable to all objects when
> blessing? At its minimal, this vtable would only need to support two
> methods: fetchmethod and ref, though more may be prudent (meta would
> be an obvious one, clone and destroy may be useful too). I think this
> would allow us to add new paradigms in a sensible and extensible way,
> without breaking too many other things.
>

Interesting! What if it was possible to overload method resolution by
placing magic on the object? The object wouldn't even need to be blessed,
so gone is the requirement for a stash. Seems this avoids all compatibility
problems while providing a completely flexible system. It would allow one
to create (a module that creates) anon classes, or even class-less objects
like in JavaScript.

- Eric

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