3 ms·
Some language implementors deliberately introduce gotchas to bite you in the ass should you rely on implementation-specific, rather than standardized, behavior.
by bitwize 8y ago
Some language implementors deliberately introduce gotchas to bite you in the ass should you rely on implementation-specific, rather than standardized, behavior.
Take this example from Scheme: R5RS specified two procedures, integer->char and char->integer, to bijectively map characters to integer character codes, but it said nothing about a specific encoding. Most Scheme implementations happily mapped characters to their ASCII codes or Unicode codepoints.
Not so Scheme48, which mapped each character to its ASCII code number plus a magic constant (believe it was 1000). Scheme48 provided library functions ascii->char and char->ascii, that did what most people actually wanted and its maintainers insisted that people use those.
Had significant code appeared in the wild that, say, simply subtracted the magic constant from the value returned by char->integer and re-added it again before calling integer->char, the maintainers probably would have either changed the magic constant, or changed the mapping entirely, in a future version.