On Mon, 30 Nov 2009, Eric Brine wrote: > On Sun, Nov 29, 2009 at 5:11 AM, H.Merijn Brand <h.m.brand@xs4all.nl> wrote: > > > If '$s = undef' is clearly not doing what might be expected, is there Depends on your expectation I guess. It is doing exactly what I expect it to do. > > any chance in breaking code when making '$s = undef' to do the same as > > 'undef $s' ? > > No, I don't see how it could. How would then set a scalar to the undefined value *without* releasing the PV buffer? > > How easy would it be to `optimize' that in perl itself? > > > > You mean remove the optimisation to prevent unnecessary calls to malloc. > > The answer might depend on exactly what you want. Do you wish to free the > scalar's buffer > > 1) When the result of a call to undef is assigned to it? > 2) When &PL_sv_undef is assigned to it? > 3) When an undefined value is assigned to it? > 4) When an undefined value is assigned to it and when it is cleared (e.g. > when it goes out of scope). > > I'm not sure it's wise to remove this optimisation for the rare occurrence > of accidentally using undef($var) instead of $var = undef in the rare > occurrence that undef($var) is needed. Agreed! I don't get the point of this discussion. undef($var) is already releasing the buffer, so you have a mechanism to tunnel through the abstraction and diddle with Perl's memory allocation strategy. Why do you need any more? And I really don't want to see any kind of "advice" that people undef() all their variables before they go out of scope. In most cases this will just make the program run much more slowly. Cheers, -JanThread Next