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

Strings lib #338

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft

Strings lib #338

wants to merge 3 commits into from

Conversation

tkers
Copy link
Member

@tkers tkers commented Mar 20, 2022

Some extra words for working with strings.

Appending strings
+PLACE (sometimes known as append) is already added to the core lib, as it's a very common (even if non-standard) word.

Appending characters or numbers
This strings lib adds c+place and #+place for appending a single character or numeric value to a string. Not sure about existing name conventions? This used to be cappend and #append, but being consistent with +place probably makes sense.

Longer counted strings
gbforth supports counted strings (and the related words place and count) that use a single char for storing the string length. This limits the length of counted strings to 255 characters.

Some forth systems use a cell (2 chars) for this, so longer strings are allowed, at the expense of using a bit more bytes for storage. While using strings that are longer than 255 characters might not be very common, it might be nice to support them anyway so that things ✨ just work ✨

Alternatively, we can include a longer-strings.fs lib that redefines the words place and +place (and any other related words) to use a cell count rather than a char count.

Todo

  • Name for char +place and num +place words
  • Consider using a CELL instead of CHAR for counted strings?

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

Successfully merging this pull request may close these issues.

1 participant