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.

Re: AUTLOAD and $_

2005-06-23 Thread Piers Cawley
Luke Palmer [EMAIL PROTECTED] writes: On 6/20/05, chromatic [EMAIL PROTECTED] wrote: On Mon, 2005-06-20 at 12:11 +0200, Juerd wrote: I think there exists an even simpler way to avoid any mess involved. Instead of letting AUTOLOAD receive and pass on arguments, and instead of letting

Re: AUTLOAD and $_

2005-06-22 Thread Maxim Sloyko
Juerd wrote: sub AUTOLOAD ($whatever) { # but no *[at]_ my $s = get_subref_for $whatever; our ::($whatever) := $s; return sub () { 1 }; Then the subref will not be executed, and the bug will very quickly be discovered. I don't see any problem with this. Can we do return

Re: AUTLOAD and $_

2005-06-22 Thread Juerd
Rod Adams skribis 2005-06-21 20:08 (-0500): Should we then perhaps rename it to: DEPRECATED_PERL5_AUTOLOAD ? That sounds like a good idea. In fact, a pragma to enable it would not be a bad idea either, IMO. Juerd -- http://convolution.nl/maak_juerd_blij.html

Re: AUTLOAD and $_

2005-06-22 Thread Juerd
Maxim Sloyko skribis 2005-06-22 14:27 (+0400): Can we do return undef in this case? I mean. can undef mean a no-op in subref context? That's a rather false value. I hope undef is not executable. It's a much better idea to special case empty closures, IMO. Juerd --

Re: AUTLOAD and $_

2005-06-22 Thread chromatic
On Tue, 2005-06-21 at 20:08 -0500, Rod Adams wrote: Should we then perhaps rename it to: DEPRECATED_PERL5_AUTOLOAD ? Poster 1: I hate it! Poster 2: I love it! Poster 3: How about PERL_5_AUTOLOAD_DO_NOT_USE? Poster 4: That's a stupid feature to add! Poster 5: That's too much to type! Isn't

Re: AUTLOAD and $_

2005-06-21 Thread Adam Kennedy
I think there exists an even simpler way to avoid any mess involved. Instead of letting AUTOLOAD receive and pass on arguments, and instead of letting AUTOLOAD call the loaded sub, why not have AUTOLOAD do its thing, and then have *perl* call the sub? sub AUTOLOAD ($whatever) { # but no

Re: AUTLOAD and $_

2005-06-21 Thread Luke Palmer
On 6/21/05, Adam Kennedy [EMAIL PROTECTED] wrote: You are of course assuming that every use of AUTOLOAD, for all time, will result in a) Calling another function b) An error Wouldn't this lead to hacks where people do things like this just to prevent perl thinking it's a failure? sub

Re: AUTLOAD and $_

2005-06-21 Thread Juerd
Adam Kennedy skribis 2005-06-21 12:10 (+1000): You are of course assuming that every use of AUTOLOAD, for all time, will result in a) Calling another function b) An error That is more or less what it's for. Do note that this other function that is called can be entirely statementless, thus a

Re: AUTLOAD and $_

2005-06-21 Thread chromatic
On Tue, 2005-06-21 at 13:35 +, Luke Palmer wrote: I think people are being pretty closed-minded about closures. I'm pretty closed-minded about writing code that does nothing to prevent the language from doing the wrong thing by default. I already have a fantastic way to write code that

Re: AUTLOAD and $_

2005-06-21 Thread Juerd
chromatic skribis 2005-06-21 9:23 (-0700): I already have a fantastic way to write code that does nothing: I don't write it. Just add braces around the thing you don't write. Juerd -- http://convolution.nl/maak_juerd_blij.html http://convolution.nl/make_juerd_happy.html

Re: AUTLOAD and $_

2005-06-21 Thread Larry Wall
On Mon, Jun 20, 2005 at 07:09:42PM -0500, Rod Adams wrote: : S10 talks about how it is AUTOSUB vs AUTOMETH (and others), but AUTOLOAD : is still around. S10 doesn't mention it, but I think it's been said that : AUTOLOAD only gets called as a last resort. Really, the only point of keeping

Re: AUTLOAD and $_

2005-06-21 Thread Rod Adams
Larry Wall wrote: On Mon, Jun 20, 2005 at 07:09:42PM -0500, Rod Adams wrote: : S10 talks about how it is AUTOSUB vs AUTOMETH (and others), but AUTOLOAD : is still around. S10 doesn't mention it, but I think it's been said that : AUTOLOAD only gets called as a last resort. Really, the only

Re: AUTLOAD and $_

2005-06-20 Thread Juerd
Sam Vilain skribis 2005-06-20 12:54 (+1200): sub AUTOLOAD($_ = $CALLER::$_, [EMAIL PROTECTED]) { In a way, $_ forms part of the prototype definition, but is out of band to the regular arguments on @_; it can't interfere with positional characteristics, or you have to shift it off before you

Re: AUTLOAD and $_

2005-06-20 Thread Juerd
Juerd skribis 2005-06-20 12:11 (+0200): sub AUTOLOAD ($w) { return our ::($w) = get_subref_for $w } sub AUTOLOAD { our ::($^a) = get_subref_for $^a } That's :=, of course. Juerd -- http://convolution.nl/maak_juerd_blij.html http://convolution.nl/make_juerd_happy.html

Re: AUTLOAD and $_

2005-06-20 Thread Sam Vilain
Juerd wrote: I think there exists an even simpler way to avoid any mess involved. Instead of letting AUTOLOAD receive and pass on arguments, and instead of letting AUTOLOAD call the loaded sub, why not have AUTOLOAD do its thing, and then have *perl* call the sub? sub AUTOLOAD ($w) { return

Re: AUTLOAD and $_

2005-06-20 Thread chromatic
On Mon, 2005-06-20 at 12:11 +0200, Juerd wrote: I think there exists an even simpler way to avoid any mess involved. Instead of letting AUTOLOAD receive and pass on arguments, and instead of letting AUTOLOAD call the loaded sub, why not have AUTOLOAD do its thing, and then have *perl* call

Re: AUTLOAD and $_

2005-06-20 Thread Sam Vilain
chromatic wrote: Who says AUTOLOAD will always either call a loaded sub or fail? Maybe it should be passed a continuation too, then? Then it could choose exactly what to do with it. Sam.

Re: AUTLOAD and $_

2005-06-20 Thread Luke Palmer
On 6/20/05, chromatic [EMAIL PROTECTED] wrote: On Mon, 2005-06-20 at 12:11 +0200, Juerd wrote: I think there exists an even simpler way to avoid any mess involved. Instead of letting AUTOLOAD receive and pass on arguments, and instead of letting AUTOLOAD call the loaded sub, why not have

Re: AUTLOAD and $_

2005-06-20 Thread Juerd
chromatic skribis 2005-06-20 14:56 (-0700): Who says AUTOLOAD will always either call a loaded sub or fail? I don't recall any clearl spec of Perl 6's AUTOLOAD. If there is something I missed, say so and please do provide example code. Questions like the one quoted tend to irritate me. There is

Re: AUTLOAD and $_

2005-06-20 Thread chromatic
On Mon, 2005-06-20 at 16:37 -0600, Luke Palmer wrote: On 6/20/05, chromatic [EMAIL PROTECTED] wrote: Who says AUTOLOAD will always either call a loaded sub or fail? Uh, what else can it do? It doesn't have to load a sub to return a code reference. I think: class NullObject { sub

Re: AUTLOAD and $_

2005-06-20 Thread Juerd
chromatic skribis 2005-06-20 15:58 (-0700): I think: sub AUTOLOAD {} is better than: sub AUTOLOAD { return sub {} } It's nicer to type, but I think that your preferred syntax means that the AUTOLOAD sub itself has to call any loaded code, which can mean that it has to fit

Re: AUTLOAD and $_

2005-06-20 Thread Rod Adams
Juerd wrote: I also don't see the symmetry between AUTOLOAD and AUTOMETH. Two things bother be about that: LOAD versus METH, while it should be SUB versus METH, and that METHOD is abbreviated while in the method keyword it is not. Either it should be abbreviated everywhere: meth foo { ... }, or

Re: AUTLOAD and $_

2005-06-20 Thread John Macdonald
On Mon, Jun 20, 2005 at 04:37:31PM -0600, Luke Palmer wrote: On 6/20/05, chromatic [EMAIL PROTECTED] wrote: On Mon, 2005-06-20 at 12:11 +0200, Juerd wrote: I think there exists an even simpler way to avoid any mess involved. Instead of letting AUTOLOAD receive and pass on arguments,

AUTLOAD and $_

2005-06-19 Thread Sam Vilain
From S10; In any case, there is no longer any magical $AUTOLOAD variable. The name being declared or defined can be found in $_ instead. The name does not include the package name. You can always get your own package name with $?PACKAGENAME. So, what is the prototype of AUTOLOAD? It is