Magic mutators and my $var is Proxy( ... );

2005-06-26 Thread Sam Vilain
To me it is a trivial case that you want to provide a fake attribute which for all intents and purposes behaves exactly like there was a real attribute there, backing against another attribute. A Date object is a classic example of this; you want to provide 0-based and 1-based attributes, which y

OO magic (at least for me)

2005-06-26 Thread BÁRTHÁZI András
Hi, I'm wondering, if it's possible with Perl 6 or not? class MyClass { method mymethod($par) { say "mymethod called!"; } } class ExClass is MyClass { mymethod(12); } #> pugs myprog mymethod called! I would like to use mymethod to add ExClass some m

Re: OO magic (at least for me)

2005-06-26 Thread Piers Cawley
BÁRTHÁZI András <[EMAIL PROTECTED]> writes: > Hi, > > I'm wondering, if it's possible with Perl 6 or not? > > class MyClass { > > method mymethod($par) { > say "mymethod called!"; > } > > } > > class ExClass is MyClass { > > mymethod(12); > > } > > #> pugs myprog >

Re: OO magic (at least for me)

2005-06-26 Thread BÁRTHÁZI András
Hi! I'm trying to answering my questions. Still interested in some official answer. :) --- 8< --- 8< --- 8< --- 8< --- 8< --- 8< --- 8< --- class MyMethod { method fun1() { fun2(); } method fun2() { say "fun2!"; } } class Child is MyMethod { } Child.fun1(); --

Re: OO magic (at least for me)

2005-06-26 Thread Juerd
BÁRTHÁZI András skribis 2005-06-26 19:35 (+0200): > method fun1() { fun2(); } > method fun2() { say "fun2!"; } > *** No compatible subroutine found: "&fun2" fun2 is a method, not a sub. You need method syntax to call it: ./fun2; > class MyMethod { method fun1() { fun2(); } sub fun2()

Re: OO magic (at least for me)

2005-06-26 Thread BÁRTHÁZI András
Hi, method fun1() { fun2(); } method fun2() { say "fun2!"; } *** No compatible subroutine found: "&fun2" fun2 is a method, not a sub. You need method syntax to call it: ./fun2; Hmm. It really works. :) I'm getting the idea, what's the difference between methods and subs. Anyway,

Re: OO magic (at least for me)

2005-06-26 Thread Juerd
BÁRTHÁZI András skribis 2005-06-26 20:07 (+0200): > Hmm. It really works. :) I'm getting the idea, what's the difference > between methods and subs. Anyway, my implementation is, that ./ means > self's method - and the class is not an instance, so it has no self. The invocant can be a class too.

Re: Magic mutators and my $var is Proxy( ... );

2005-06-26 Thread Sam Vilain
Sam Vilain wrote: To me it is a trivial case that you want to provide a fake attribute which for all intents and purposes behaves exactly like there was a real attribute there, backing against another attribute. A Date object is a classic example of this; you want to provide 0-based and 1-based

Re: AUTLOAD and $_

2005-06-26 Thread Sam Vilain
Piers Cawley wrote: For myself, I'd like to see AUTOLOAD with a signature along the lines of: sub AUTOLOAD (Symbol $sym, ArgumentCollection $args, Continuation $cc) returns (Code | Pair) { ... } This presupposes a deal of support infrastructure, but also provides flexibility. F

Re: Magic mutators and my $var is Proxy( ... );

2005-06-26 Thread Luke Palmer
On 6/26/05, Sam Vilain <[EMAIL PROTECTED]> wrote: > So, we've got this "my $var is Proxy( ... )" construct in A06. > Say you've got this class: > >class MagicVal { > has Int $.varies is rw; > > method varies returns Int is rw { > return my $var is Proxy ( :for($.varies), >