http://qs1969.pair.com?node_id=66695


in reply to A (kinda) Circular Cache

I like it!

Meaningless 'optimization'/alternate style: I like to do my defaults right when I declare the variables; not that it matters much here, but just as a 'grace note':

my $size = shift || 30;

Also,

return unless defined $data; $data;

in your get method will return undef if $data is not defined (at least, if the sub's been called in a scalar context, which it will be, right?), so you could probably just get rid of that first line.

well, I guess it saves a few keystrokes too ... heh.

Philosophy can be made out of anything. Or less -- Jerry A. Fodor

Replies are listed 'Best First'.
Re: Re: A (kinda) Circular Cache
by mr.nick (Chaplain) on Mar 24, 2001 at 00:06 UTC
    in your get method will return undef if $data is not defined (at least, if the sub's been called in a scalar context, which it will be, right?), so you could probably just get rid of that first line.

    Hehe, I'm terrified of that situation now. I spent probably 10 hours a couple of weeks ago tracking down a problem that was caused by scalar/array contexts and "return" vs. "return undef". I'm playing it safe from now on.

    Should have did the $size=shift || 30 thing myself though!