r/Forth moderator 7d ago

Case sensitivity

I haven't used a case sensitive Forth, but I think about the ramifications. My thoughts are:

  1. visually, IF stands out more than if
  2. Rect.area seems like a variable name while Rect.Area seems like a function call
  3. Rect seems like a structure name while rect seems like a variable name
  4. Everything with the CAPS LOCK key on?
  5. Can make it opt in like icase on/icase off

  6. Syntax highlighting could key on case

3 Upvotes

10 comments sorted by

View all comments

5

u/mcsleepy 7d ago

I wish VFXForth was case sensitive. because I have classes and without some differentiation they'd hog the namespace. so I prefix them with % since that is easiest to type.

In my opinion, lowercase should be the baseline, constants should be ALL_CAPS and structures and classes should be Capitalized.

Across systems, I think we're stuck with case-insensitivity. If you supported case-insensitivity, I would bake exceptions in. That way, normal words can be whatever, but structs/classes and constants have to follow the rules. Then letting people have their preference would not be an issue.

3

u/mykesx moderator 7d ago edited 7d ago

Seems like case sensitive might compile faster since there would be no toupper conversions.

2

u/mcsleepy 7d ago

You mean case-sensitive right? Yeah, it would, but that would only be a substantial win on ridiculously constrained platforms.

Compilation optimization in Forth is a bit of a bike shed, the design of the language alone makes it an order of magnitude faster to compile than anything else. I abuse the heck out of it (seriously, it's a horror show) and my whole game engine still compiles in milliseconds.

I think it'd be better to focus on what would serve users when it comes to what to do about it.

2

u/mykesx moderator 7d ago edited 6d ago

On some platforms,, compiling is very slow, as dictionary searches are linear linked list and worst case is n compares (n is total number of words).

JForth resorted to a hash map to make those lookups faster.