racket / htdp

Other
91 stars 69 forks source link

Fix constructor-style printing for hashes. #221

Open mikesperber opened 2 months ago

mikesperber commented 2 months ago

Fixes #220.

Wrap a struct around hashes that has a custom print-converter.

NOTE: While this works correctly in the #langs, this fails the tests in htdp-test/tests/htdp-lang/advanced.rktl, as they pick up the correct binding for make-hash, but not for make-copy etc.

mikesperber commented 2 months ago

I could use some help with this PR: I don't know why the tests pick up the correct binding for make-hash, but the original binding for make-copy etc.

rfindler commented 2 months ago

I think we probably want to change some printing code for the existing hashes, not make a new struct. With a new struct then others' libraries won't work right anymore.

Robby

mikesperber commented 2 months ago

@rfindler Sure - but I think this reveals that the concept of print-convert is ultimately flawed, as you really need to parameterize everything about it. It would be better to be able to register a lang-specific function that does all of the work, and maybe provide a library of helpers that this function could call.

mikesperber commented 1 week ago

@rfindler Bump ... on adding the necessary option to print-convert, as discussed today.