[tpm] Is there a three-way version of...

Shaun Fryer sfryer at sourcery.ca
Sat May 30 14:20:56 PDT 2009


> i generally don't like using shift on @_ and prefer to assign it.

True for complex stuff. My feeling is that when it's a very short
method (one liner), like a simple accessor, shift is faster (from
benchmarks I've seen) and not unclear/unmaintainable. For instance...

    sub foo { return shift()->{foo} = shift if @_ }

...seems quite reasonable to me. YMMV

> never duplicate deep access code. use a temp var with the lower level
> reference and it will be clearer and if you do need multiple uses, faster.

Seems reasonable.

> ...in the bizarre case of someone setting $] which changes the index origin,
> @array will stay the same but $#array will change.

Good point.

Thanks for the input.

Cheers,
Shaun


More information about the toronto-pm mailing list