Refactor en route to #5027 -- remove usestring parameter from lookupvar
The usestring parameter to lookupvar was objectionable for several reasons;
first, it performed a function orthogonal to the main purpose of the method,
second its default was the least common value, and third it was causing other
code to work for reasons that were not obvious (extlookup).
This refactor breaks the value-transforming function out into a seperate
method which allows the user to specify the value to be used in lieu of :undef
and removes the parameter. The function, Scope#undef_as(default,exp) is
written so that it can be used in user code (templates, functions, etc.) if
needed.
This refactor will introduce a user-visible behaviour change in the case where
users were counting on lookupvar to return "" for undefined variables. The
best solution is to have them use undef_as, replacing:
lookupvar('myvar')
with
undef_as('',lookupvar('myvar'))
(with the option to specify another default value if desired). If this is too
objectionable, we could rename the existing lookupvar as raw_lookupvar and
define
def lookupvar(v) undef_as('',raw_lookupvar(v)) end
to restore the present behaviour.