Stefan (>):
> A methodical is an operator which syntactically behaves as a method but is
> subject to scoping rules. Methodicals are defined using the ordinary method
> keyword, qualified with my or our. (TODO: This seems the most natural syntax
> to me, but it conflicts with existing usage. Whi
On Wed, Apr 21, 2010 at 12:35:11PM -0300, Daniel Ruoso wrote:
> Em Qua, 2010-04-21 às 00:16 -0700, Stefan O'Rear escreveu:
> > Normally, when you write a method call, the definition of the method is
> > entirely in the domain of the receiver's class:
> > $object.make-me-a-sandwich; # $object g
Em Qua, 2010-04-21 às 00:16 -0700, Stefan O'Rear escreveu:
> Normally, when you write a method call, the definition of the method is
> entirely in the domain of the receiver's class:
> $object.make-me-a-sandwich; # $object gets to decide what this means
Actually, this is delegated to the disp
That's lifetime of the object, which is still monkeytyping, just on a less
global level than modifying the class directly.
Compare the Ruby example to this: (syntax is entirely made up):
my $foo = SomeClass.new;
{
methodical bar(SomeClass) { say "Hello, world!" }
$foo.bar # "Hello, worl
Ruby has a similar functionality that lets you define methods on an instance
object. Really, its how class methods are specified, you just put the class
name as the name of the object. Here is an example:
a = Object.new
def a.foo
puts "foo and #{self}"
end
They will stay on the object as long
This idea strikes me as being extremely similar to C#'s extension
methods, a feature that I've found to be particularly beneficial in
many cases. The fact that these methodicals are lexically-scoped is
especially nice, and the fact that they can be applied post-hoc to
arbitrary data items that have
(The following describes a proposed extension to Perl 6, methodical scoped
operators or methodicals for short. It is written in the present tense for
simplicity but should be understood as the future conditional.)
Normally, when you write a method call, the definition of the method is
entirely in