In perl.git, the branch smueller/hash_vtable_make_hash has been created
<http://perl5.git.perl.org/perl.git/commitdiff/21241ff4cd37bb2b8b324be6b3a2c1122e911a8c?hp=0000000000000000000000000000000000000000>
at 21241ff4cd37bb2b8b324be6b3a2c1122e911a8c (commit)
- Log -----------------------------------------------------------------
commit 21241ff4cd37bb2b8b324be6b3a2c1122e911a8c
Author: Steffen Mueller <[email protected]>
Date: Mon Jan 30 09:22:05 2017 +0100
Hash vtables: First stab at implementing an interface
This introduces a new module, Hash::Pluggable. It provides a new keyword
"make_hash" (better naming suggestions welcome) which acts just like a
normal anon hash constructor, {}, in that is creates and returns a hash
ref. It's implemented as a custom OP very similar to the actual
OP_ANONHASH.
It does, however, use its first argument to determine its hash type.
As of this commit, it will use it to look up the vtable to use in a
global registry at run time.
What's missing:
- A way to add vtables to the registry.
- Erroring out if it's an unknown vtable.
- Moving the lookup to compile time... but...
- So it should be possible to do this lookup at compile time if it's
a static string. This is still TODO.
- This does unfortunately pose a problem in that it would make
behavior inconsistent. With that, if it's a static string, the
vtable would be looked up at compile time. If it's an expression,
the vtable would be looked up at run time. I'm not sure how big a
deal this is necessarily (seems less bad than trying to randomly
evaluate some expression at compile time!), but it means that the
state of the vtable registry could change inbetween.
-----------------------------------------------------------------------
--
Perl5 Master Repository