Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Long name support #182

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Long name support #182

wants to merge 3 commits into from

Conversation

robzed
Copy link
Contributor

@robzed robzed commented Dec 27, 2024

This adds long word name support.

Questions:

  1. Currently this is gated by a #define LONG_NAME_SUPPORT - currently enabled, but it can be build without to support old dictionaries with a build - however, maybe we should remove this and only support long names?

  2. I added two Primitive Token IDS - which expose the FLAG_SMUDGE and MASK_NAME_SIZE ... these allow the Forth files to not have magic numbers unrelated to the Forth core... I can understand why we didn't do this in the past (size), but I think the dependency is strong between the two - and the Forth code is clearer for it. However it is a design decision - so should we do this or revert this part?

  3. I left FLAG_PRECEDENCE commented out - maybe this should be removed.

Name to long warnings/errors to be raised as a separate PR.

Copy link
Owner

@philburk philburk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks really good!
Let's keep it switchable. That will make it easier to debug if there is a name size
related problem.

/* Most Forth word names are short - so 31 characters should be enough.
* However if you are integrating with other systems - for example libSDL
* some names are longer than 31 characters. This provides up to 63 characters
* for a word names.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* for a word names.
* for word names.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could also be convinced to just make long names the default. Hmm.

* Long term this can become the default since there is no storage penalty
* when not using them.
*/
#define LONG_NAME_SUPPORT
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's make this like the other compile time switches defined at:

https://www.softsynth.com/pforth/pf_ref.php#Compiler-Options

Let's rename it to PF_SUPPORT_LONG_NAMES
and leave it undefined for now.
Maybe we can test it on/off in GitHub Actions.

@@ -63,10 +80,19 @@
#define FTRUE (-1)
#define BLANK (' ')

#define FLAG_PRECEDENCE (0x80)
/* #define FLAG_PRECEDENCE (0x80) */
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add:
/* The IMMEDIATE flag is known as the "precedence bit" on some other Forth systems. */

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants