Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rakudo inappropriately uses .gist for caching "is cached" sub arguments; needs proper solution #3722

Open
p6rt opened this issue Mar 8, 2015 · 3 comments
Labels
NYI Features not yet implemented

Comments

@p6rt
Copy link

p6rt commented Mar 8, 2015

Migrated from rt.perl.org#124016 (status was 'open')

Searchable as RT124016$

@p6rt
Copy link
Author

p6rt commented Mar 8, 2015

From @smls

In current Rakudo, the 'is cached' trait for routines compares incoming argument lists by their .gist representation. This was probably done as a temporary work-around, and is not a satisfactory solution because​:

* .gist elides information (e.g. cutting off lists/arrays after the first few elements), thus causing false positives.

* .gist is explicitly meant as a summary for human consumption, and not for hashing/comparing objects.

IRC discussion of the problem​:

masak​: 'is cached' does some "snapshotting" of the incoming maybe-reference
  value, and it's that thing that's being eqv-compared with what's in
  the cache. (though right now it's being .gist-compared, which may or
  may not be goodenuf)
smls​: well, seeing how gist truncates lists/arrays, it seems a little unsafe
masak​: yes, that's a *bug*
masak​: actually, knowing that, using .gist in the first place is *wrong*,
  because the story for .gist is "string summary for human/screen
  consumption", not "exact eqv-like value for things like hashing"

IRC discussion about what a proper solution might look like​:

TimToady​: I think each immutable type should have a hash function of some
  sort, and mutable types a way to snapshot to eqv semantics
masak​: that sounds good so far, but I think we need more than that.
TimToady​: well, and a well-defined stragegy for combining hashes
masak​: also, some things (like filehandles) probably don't have a good
  immutable/eqv representation.
TimToady​: for filehandles and VAR($x) hashing the WHICH is probably as good
  as we can do
masak​: right. that has to be an allowable fallback.

@p6rt
Copy link
Author

p6rt commented Dec 11, 2015

From @jnthn

On Sun Mar 08 07​:02​:33 2015, smls75@​gmail.com wrote​:

In current Rakudo, the 'is cached' trait for routines compares
incoming argument lists by their .gist representation. This was
probably done as a temporary work-around, and is not a satisfactory
solution because​:

* .gist elides information (e.g. cutting off lists/arrays after the
first few elements), thus causing false positives.

* .gist is explicitly meant as a summary for human consumption, and
not for hashing/comparing objects.

IRC discussion of the problem​:

masak​: 'is cached' does some "snapshotting" of the incoming maybe-
reference
value, and it's that thing that's being eqv-compared with
what's in
the cache. (though right now it's being .gist-compared, which
may or
may not be goodenuf)
smls​: well, seeing how gist truncates lists/arrays, it seems a
little unsafe
masak​: yes, that's a *bug*
masak​: actually, knowing that, using .gist in the first place is
*wrong*,
because the story for .gist is "string summary for
human/screen
consumption", not "exact eqv-like value for things like
hashing"

IRC discussion about what a proper solution might look like​:

TimToady​: I think each immutable type should have a hash function of
some
sort, and mutable types a way to snapshot to eqv semantics
masak​: that sounds good so far, but I think we need more than
that.
TimToady​: well, and a well-defined stragegy for combining hashes
masak​: also, some things (like filehandles) probably don't have a
good
immutable/eqv representation.
TimToady​: for filehandles and VAR($x) hashing the WHICH is probably
as good
as we can do
masak​: right. that has to be an allowable fallback.

Since there was no obvious solution in sight, and there were other issues with "is cached", we've decided to defer this functionality to a future Perl 6 language version. So, removing it from the xmas list.

@p6rt
Copy link
Author

p6rt commented Dec 11, 2015

The RT System itself - Status changed from 'new' to 'open'

@p6rt p6rt added the NYI Features not yet implemented label Jan 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NYI Features not yet implemented
Projects
None yet
Development

No branches or pull requests

1 participant