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: Customizable default hash and array values.
by Dan Sugalski other posts by this author
Sep 25 2001 10:53PM messages near this date
Re: Customizable default hash and array values. | Re: Customizable default hash and array values.
At 10:06 PM 9/24/2001 -0400, Michael G Schwern wrote:
> Wouldn't it be nice if there was a way to change the default value of

> a hash?  So instead of undef you'll get whatever default you like?


Sure, I don't see why not. The hash access function is responsible for 
returning a value, so there's no reason you shouldn't be able to override 
it. Whether that's a core feature now is another issue, of course, but 
there won't be anything to stop you. You can also do trickery to not 
autovivify elements of the array or hash if they're only read and don't exist.

I'm pretty sure you can do this now with tie, but that's kind of heavy-weight.

					Dan

--------------------------------------"it's like this"-------------------
Dan Sugalski                          even samurai
dan@[...].org                         have teddy bears and even
                                      teddy bears get drunk


Thread:
Michael G Schwern
RaFaL Pocztarski
Johan Vromans
Bart Lateur
Michael G Schwern
Bart Lateur
Michael G Schwern
Dan Sugalski
David Grove

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