anyway I think it's a notable result of this discussion that the location of constants and literals will not be fixed at compiletime!
That's not true. Constants are allocated once at compile time.
for (1..3) { print(\1, "\n"); push @x, 'x'; # Prevent reuse of memory addresses. }
SCALAR(0x236d94) SCALAR(0x236d94) SCALAR(0x236d94)
They are tied to the opcode, and the same constant is returned every time.
PP(pp_const) { dVAR; dSP; XPUSHs(cSVOP_sv); RETURN; }
If you see otherwise, it's because you're looking at a *copy* of the constant.
Note that different instances of the same literal results in different constants.
for (1..3) { print(\1, ' ', \1, "\n"); push @x, 'x'; # Prevent reuse of memory addresses. }
SCALAR(0x236d94) SCALAR(0x183179c) SCALAR(0x236d94) SCALAR(0x183179c) SCALAR(0x236d94) SCALAR(0x183179c)
In reply to Re^9: Reference of constants and literals
by ikegami
in thread Reference of constants and literals
by LanX
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |