ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> perl6-language
perl6-language
Re: AUTLOAD and $_
by Juerd other posts by this author
Jun 21 2005 9:06AM messages near this date
Re: AUTLOAD and $_ | Re: AUTLOAD and $_
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 no-op.

>  Wouldn't this lead to hacks where people do things like this just to 
>  prevent perl thinking it's a failure?

There is nothing we can do to prevent dumb programmers from doing dumb
things, except dropping lots of features and operators. But if we wanted
that, adding lexicals and closures to PHP would probably be easier.

>  sub AUTOLOAD ($whatever) {  # but no *@_
>       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.

There are also people who don't understand that TIE* methods should
return objects, because they are constructors. Has this ever been a
great problem? 

If there is a fixed interface that makes sense and is documented, people
not following it are either really dumb or very clever. 

>  The ability to get complete control over the params and context of the 
>  function, and maybe run something else AFTER the function call is important.

I disagree. In that case you should be using a wrapper or a macro. A
wrapper you can simply return, but I find it very bad style to install
foo and then run foo plus something else. And if you don't install foo
(with &foo := ...), you can do whatever you want anyway, by putting
whatever you want in the closure.

>  So I suspect there might be some false economy in this optimisation.

It's not an optimization. It's necessary, unless there is a way to
receive arguments in unknown context, which is a bit of complexity and
complication we can very easily avoid needing.


Juerd
-- 
http://convolution.nl/maak_juerd_blij.html
http://convolution.nl/make_juerd_happy.html 
http://convolution.nl/gajigu_juerd_n.html
Thread:
Sam Vilain
Juerd
Sam Vilain
Maxim Sloyko
Juerd
Adam Kennedy
Juerd
Luke Palmer
Chromatic
Juerd
Chromatic
Juerd
Luke Palmer
John Macdonald
Chromatic
Juerd
Rod Adams
Larry Wall
Rod Adams
Chromatic
Juerd
Sam Vilain
Sam Vilain
Juerd

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved