Re: Customizable default hash and array values.

2001-09-24 Thread David Grove
I think this is one of many steps in the right direction. Actually, I have a class item defined in my fork as: class foo reserve bar scalar; member bar { default(bar) = '1'; set(bar) = {some code}; get(bar) = {some code}; ensure(bar) = {some code}; confirm(bar) = {some co

Re: Custom iterators

2001-09-24 Thread Michael G Schwern
On Mon, Sep 24, 2001 at 10:38:44PM -0400, Bryan C. Warnock wrote: > On Monday 24 September 2001 09:58 pm, Michael G Schwern wrote: > > yield() [2] simply says "run the block associated with this method > > once". Similar to the $block->() call, but since it's not a full > > subroutine call, just

Re: Custom iterators

2001-09-24 Thread Bryan C . Warnock
On Monday 24 September 2001 09:58 pm, Michael G Schwern wrote: > yield() [2] simply says "run the block associated with this method > once". Similar to the $block->() call, but since it's not a full > subroutine call, just a block enter/exit (like a normal iteration > through a loop) there's two

Customizable default hash and array values.

2001-09-24 Thread Michael G Schwern
How many times have you written this (well, since this is Perl 6 grammar, you've probably *never* written this, but you get the idea) my $foo = %hash{$key} || 'some default'; Annoying, and you've got to scatter this sort of thing all over the code, even if just to avoid "use of uninitialized

Custom iterators

2001-09-24 Thread Michael G Schwern
The normal, efficient Perl 5 way to open a file and do work on it. open FILE, "some/file"; while() { print; } close FILE; Now consider this Perl 5 code that does the exact same thing. foreach_line { print } 'some/file'; Ok, that's sort of neat. Very compact. Minim