Yes, absolutely, about the semantics.
About the syntax, how about just in a block behind %HASHNAME?
(as long as it doesn't use $a and $b, of course )
(or if the insta-sort thing needs "sort" written in and this doesn't)
%record{
$something_new = 3; # just set $record{something_new} to 3
};
Dave Storrs wrote:
>
> On Wed, 16 Aug 2000, David L. Nicol wrote:
>
> > a more general "with" keyword
> > which would operate on a hash and be syntactic sugar for
> > replacing all appearances of unqualified variables that match
> > the hash's keys with references into it?
>
> 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.
No keyword at all! Better that
> 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.
Right. Which is why I wanted to restrict them to listed-keys structs,
should such exist.
People would be confused.
Instead of just running s/\$(\w+)/\$${hashname}\{$1\}/g on the whole inner
block, we'd have to check for definition both in the hash and in the outside
world before creating new elements in the hash.
Or maybe EVERYTHING would be in the hash, as if it was the new top-level-name-space
for the following block, and if you wanted to access a variable that was not
in the hash already you either couldn't or you'd have to get to it via some
kind of alternate naming, like prefacing it with :: or something. So you'd
want to set mutexes around your with blocks on any package lexicals you're going
to use inside of them.
--
David Nicol 816.235.1187 [EMAIL PROTECTED]
Does despair.com sell a discordian calendar?