On 2019-05-22T11:18:33+01:00, SCHROEER wrote:
Show quoted text> The 'values' attribute/method of Type::Tiny::Enum returns a sorted list of
> the allowable value strings. That's an incompatibility to Moose's type
> constraint API where the specified order is maintained. I prefer Moose's
> behaviour.
It also removes duplicates from the list. It tries to cut things down to the essentials to make the check as efficient as possible. For example, if you consider:
use feature 'say';
use Types::Standard -all;
use Scalar::Util 'refaddr';
say refaddr($_->compiled_check) for Enum[qw(Y N)], Enum[qw(N Y)];
You'll see that the coderef returned by $type->compiled_check for both those enums has the same refaddr. It's reused the same coderef. So I certainly want to keep the current sorting and deduplication to "canonicalize" the list.
But it should also be possible to retain a copy of the original list for introspection purposes, have the `values` method return that original list, and add a new method to return the canonicalized list.
I'd probably also need to go through the code and figure out what other places are using the `values` method and expecting the canonicalized list, but that's probably not a lot of work.
If you can submit some test cases for the behaviour of `values` that you expect, I can try to work it in before 1.006000.