Commit Graph

3 Commits

Author SHA1 Message Date
Michael Herold 15ea67ef06
Add a PermissiveRespondTo extension for Mashes
By default, Mashes don't state that they respond to unset keys. This
causes unexpected behavior when you try to use a Mash with a
SimpleDelegator.

This new extension allows you create a permissive subclass of Mash that
will be fully compatible with SimpleDelegator and allow you to fully do
thunk-oriented programming with Mashes.

This comes with the trade-off of a ~19KB cache for each of these
subclasses and a ~20% performance penalty on any of those subclasses.
2019-11-17 11:36:31 -06:00
Michael Herold 9f77380ddb
Add performance benchmarks for Mash 2017-02-24 07:11:34 -06:00
Michael Herold c071e4f9fd Add an extension to maintain original Mash keys (#326)
One of the behaviors of Mash that we see regularly surprise users is
that Mash stringifies any keys passed into it. This leads to unexpected
lack of synergy between Mash and its cousins (particularly Dash), since
the property DSLs do not handle indifferent key access.

This extension ensures that the original keys are kept inside the Mash's
data structure, at the expense of more costly logic for fetching
information indifferently. I have included a benchmark that compares the
two. The benchmark shows that when you are passing string keys into a
Mash, using this extension will actually be _faster_ than the default
implementation, but that the reverse is true when passing symbol keys.

In #296, I tried to do this universally for all Mashes, which slowed
down the fetching behavior for Mash significantly. I like this attempt
much better because it allows users to opt into the new behavior if they
want it, while still keeping the default implementation as-is.

Fixes #196 by giving the option of keeping the original structure of the
Mash when using it with Dash.

Fixes #246 by giving the option of opting into keeping the original
keys.

Closes #296 by giving a more flexible path forward that doesn't change
the semantics of the main Mash class.
2017-02-22 19:37:07 -06:00