larsbrinkhoff / lbForth

Self-hosting metacompiled Forth, bootstrapping from a few lines of C; targets Linux, Windows, ARM, RISC-V, 68000, PDP-11, asm.js.
GNU General Public License v3.0
418 stars 112 forks source link

min vs umin for size #22

Closed ruv closed 8 years ago

ruv commented 8 years ago

Why do you use min but not umin in the code like the following:

: name, ( a u -- ) #name min dup c, tuck move, offset, ;

Here min protects against too long u, but not from negative u (or very long positive ;).

larsbrinkhoff commented 8 years ago

Sorry, just sloppiness. It really should be umin. But I suppose it doesn't matter much, because strings rarely are that long.

ruv commented 8 years ago

Yes, strings themselves are usually not so long. Negative length can be result of a bug in calculations with address arithmetic.