Perl: the Markov chain saw | |
PerlMonks |
Re^2: what would you like to see in perl5.12? (meth protos)by tye (Sage) |
on Aug 22, 2007 at 01:43 UTC ( [id://634226]=note: print w/replies, xml ) | Need Help?? |
That impact of prototypes requires compile-time knowledge which means that this proposal would require compile-time binding of a interface to the scalar variable that will hold the object (and run-time checking that any objects assigned to that scalar implement that interface). So this would only be possible with the use of attributes on variables. But that also limits the cases when it works. For examlpe, you could not get a prototype to be in effect for more complex code like $group->get($x)->runcode { ... } unless there was a way to compile-time declare that the variable $group must always implement an interface that includes a get() method that returns an object that always implements an interface that has a runcode(&) method. And you see how complicated that quickly gets. For other than the simplest case (calling methods directly via a scalar variable) you need to add a whole lot of static analysis abilities to the Perl compiler. I'm not saying that any of this is impossible, or even that it will never happen, but I think it is worth knowing a bit of what would be required. - tye
In Section
Meditations
|
|