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

Re: Objects without stashes?

Thread Previous | Thread Next
Eric Brine
May 25, 2012 10:40
Re: Objects without stashes?
Message ID:
On Fri, May 25, 2012 at 10:47 AM, Leon Timmermans <> 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 Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About