In perl.git, the branch smueller/hash_vtable_make_hash has been created <http://perl5.git.perl.org/perl.git/commitdiff/c852987cc09f01373754d0344a2b5f5e979471f5?hp=0000000000000000000000000000000000000000>
at c852987cc09f01373754d0344a2b5f5e979471f5 (commit) - Log ----------------------------------------------------------------- commit c852987cc09f01373754d0344a2b5f5e979471f5 Author: Steffen Mueller <smuel...@cpan.org> Date: Wed Feb 1 19:59:06 2017 +0100 Hash vtables: Fall through to runtime evaluation if vtbl not found If the vtable for a given constant string isn't found, we simply do the evaluation (again) at run-time. Until then, somebody may have added the right vtable to the registry. This means that compile/run-time behavior change that the previous commit introduced ("foo" vs. $foo as first argument to make_hash) is MOSTLY dealt with. The only remaining exception is that if somebody overwrites a vtable entry in the global registry. But that's so naughty that I think it's okay just to document not to do that. (You need to really know what you're doing if you'd be writing your own hash tables for perl anyway.) This does have one ancillary downside: We don't get compile time exceptions on invalid vtable names any more and downgrade them to runtime exceptions. That seems worth it, considering it fixes an ugly wart. M ext/Hash-Pluggable/Pluggable.xs commit d57c06546eee71e4f77813c2a725505a9b4d0e10 Author: Steffen Mueller <smuel...@cpan.org> Date: Wed Feb 1 19:56:08 2017 +0100 Hash vtables: Evaluate constant strings for vtbls at compile time With this change, "make_hash("some_vtable_name", ...)" will be resolved to a vtbl pointer (corresponding to 'some_vtable_name') at compile time. This speeds up make_hash by a factor of several (roughly 3x) in such cases. M ext/Hash-Pluggable/Pluggable.xs commit 3d6235022779c1902a9a31c28d8c8386334678bf Author: Steffen Mueller <smuel...@cpan.org> Date: Mon Jan 30 20:09:22 2017 +0100 Hash vtables: Add std mock vtable to registry M ext/Hash-Pluggable/Pluggable.xs M ext/Hash-Pluggable/lib/Hash/Pluggable.pm commit f527f1439509dcd987de8ee60fb7a37717659cd0 Author: Steffen Mueller <smuel...@cpan.org> Date: Mon Jan 30 12:46:26 2017 +0100 Hash vtables: Extend Hash::Pluggable hobo-docs M ext/Hash-Pluggable/Pluggable.xs commit 055b7de0ecdc55fcae2cc78bc1ff09db61af65fc Author: Steffen Mueller <smuel...@cpan.org> Date: Mon Jan 30 12:40:11 2017 +0100 Hash vtables: Remove debugging code M ext/Hash-Pluggable/Pluggable.xs commit 7f9ca9a2666b987be2c318d54f06d44100d78571 Author: Steffen Mueller <smuel...@cpan.org> Date: Mon Jan 30 12:39:42 2017 +0100 Hash vtables: Hobo-documentation in the sources At least explain what this does in a comment for future me. :) M ext/Hash-Pluggable/Pluggable.xs commit f6cbeef884dc98992f10042341b90f6b0af888bc Author: Steffen Mueller <smuel...@cpan.org> Date: Mon Jan 30 12:38:55 2017 +0100 Hash vtables: croak on invalid vtable names M ext/Hash-Pluggable/Pluggable.xs commit 5a1c63d26984565380045cd10ccdf79cb9aefc97 Author: Steffen Mueller <smuel...@cpan.org> Date: Mon Jan 30 12:38:07 2017 +0100 Hash vtables: Eschew mortal copy I don't think it's necessary here as we're not looking to co-opt it into a hash key. M ext/Hash-Pluggable/Pluggable.xs commit b03980364cfd4b15e7567bd41f84fd415b7479b8 Author: Steffen Mueller <smuel...@cpan.org> 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. M MANIFEST M Makefile.SH A ext/Hash-Pluggable/Pluggable.xs A ext/Hash-Pluggable/lib/Hash/Pluggable.pm A ext/Hash-Pluggable/t/01basic.t ----------------------------------------------------------------------- -- Perl5 Master Repository