develooper Front page | perl.perl5.porters | Postings from September 2002

keys.pm lexical scoping issues

Thread Previous | Thread Next
From:
Brian Ingerson
Date:
September 29, 2002 15:05
Subject:
keys.pm lexical scoping issues
Message ID:
20020929150527.B1899@ttul.org
I'm trying to figure out what the lexical context of keys.pm would be.

For instance, does 'use keys; no keys;' affect the hashing operations of
all hashes in the scope? Or does it affect only hashes that are defined
in that lexical scope? And what happens with hashes that are defined
under 'use keys', but are operated on under 'no keys'?

My gut feeling tells me that 'use keys' turns on complex-key
functionality for all hashing operations in that scope. All hashes are
equal. None are marked as complex-key-compliant. So the scoping applies
to the code, not the data.

This means, of course, that when using complex-keys, all code affecting the
data must also 'use keys' or stringification would happen. I wonder what the
larger ramifications of this are. The quandry is this:

  - We choose to use a pragma because:
    - No risk to normal speed
    - No risk to backwards compatability
  - By using a pragma, we create sets of code that act differently:
    - Modules that don't use the pragma might munge complex-keys of
      hashes passed to them by complex aware code
    - Modules that do use the pragma, incur the risks above
  # Isn't YAML fun? sorry...

Schwern would argue that we don't know the risks yet. And I tend to think
that anyone using the pragma just needs to be aware of the consequences.

Any other thoughts?

Cheers, Brian

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About