in reply to Re: Reference of constants and literals
in thread Reference of constants and literals

Well it's a question of weird optimization, a constant scalar is passed in a certain snippet of code, so no need to switch the reference at runtime.

This works with explicit refs like [1,2] and {1,2} but not with constants, they needlessly get at runtime a new reference, each time the loop gets there... just compare: check(qw/ Scalarref \1 /);

OUTPUT

--- Scalarref for (1..3) { pr \1; print "\n\t"; #UPDATE for (1..3) { pr \1; } print "\n"; } REF(0x8190768) REF(0x8190744) REF(0x8190750) REF(0x8190744) REF(0x8190750) REF(0x8195394) REF(0x8190744) REF(0x8195394) REF(0x8190744) REF(0x8190768) REF(0x8195394) REF(0x8190768)
each time a new ref instead of one ref

Cheers Rolf