On Wed, 16 Aug 2000, David L. Nicol wrote:
> Anyone for generalizing "select" to a more general "with" keyword
> which would operate on a limited hash and be syntactic sugar for
> replacing all appearances of unqualified variables that match
> the hash's keys with references into it?
>
> %record = loadrecord($studentID);
> with %record {
> print <<SPAM;
> Dear $Name:
> Your tuition is now due. Please send in a payment
> of at least $Minumum.
>
> SPAM
>
> # anyone for having a python-like floating left edge for
> # retaining indentation of hereis strings?
>
> };
I find myself very much of two minds...I think the like the
general idea, but not the implementation. A couple of thoughts:
1) The keyword should not be "with". While that would make it
more familiar to Pascal programmers, I don't feel that should be a major
incentive to choose a suboptimal keyword and, IMHO, we can do better. I
prefer "express"; it's a synonym of "import", and it seems
descriptive...you are "express"ing the keys of your hash as new scalars.
2) "express" should guarantee that, before it creates a variable
names $FOO, it first calls "local" on any existing $FOO
3) The new variables should be lexicals, defined only within the
"express" block, so that you don't pollute your namespace.
Dave