htdp icon indicating copy to clipboard operation
htdp copied to clipboard

BSL decimal number values paste as non-textual

Open rxg opened this issue 4 years ago • 6 comments

When BSL is set to display rational numbers as decimal, evaluating them produces a non-textual value that is easily mistaken for being textual. Then if a student copies and pastes such a value into their racket file, the value pastes as non-textual and the file becomes non-textual. This breaks course infrastructure that depends on receiving textual files, and is quite difficult for course staff, let alone students, to understand, and they are far more difficult to find than images or comment boxes since they look exactly like text.

rxg avatar Feb 12 '21 21:02 rxg

I think it would make sense to have the ones that are in decimal "mode" and have a finite decimal representation to turn back into text when they are inserted into a buffer. One way to do this is to get some cooperation from the text% they are pasted into (or, in other words, the existing APIs make this a change that has to go into several places with this approach). But it might also work for the copy method and the read methods to detect this situation and actually produce string-snip%s. I'm not sure if that will break other invariants that rely on, say, copy's result having the same class as the input but it seems like it might be worth a try.

This is the relevant code.

rfindler avatar Feb 12 '21 21:02 rfindler

Do we still think the snip-based decimal printing provides enough value to keep it in general? Is there some aspect of a textbook or course that relies on it?

samth avatar Feb 13 '21 00:02 samth

Backwards compatibility :-) !!

mfelleisen avatar Feb 13 '21 05:02 mfelleisen

Well, if there are things that rely on that printing, then I would want to keep it.

samth avatar Feb 13 '21 12:02 samth

I played around with this a little bit and it seems like the best approach is to make the definitions window specifically replace number snips that look like ascii with actual ascii, when the snips are inserted. I tried various tricks with the write method of the snipclass or the copy method of the snip and they didn't seem to work very well. It would mean we'd lose the snips when they are in the REPL.

It might also work to try to do something specific to the definitions window when saving but I didn't try that.

rfindler avatar Feb 13 '21 13:02 rfindler

The latest snapshots from northwestern (and maybe the Utah ones too, didn't check) have these changes in them.

Also, @dvanhorn maybe be interested in this.

rfindler avatar Feb 14 '21 13:02 rfindler