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

Add .S to core words #15

Open
MaxBarraclough opened this issue Mar 16, 2024 · 2 comments
Open

Add .S to core words #15

MaxBarraclough opened this issue Mar 16, 2024 · 2 comments

Comments

@MaxBarraclough
Copy link

The .S word is defined in calc.f as:

: .S
 ." STACK: "
  DEPTH 15 AND DUP
  IF DUP 0 DO DUP PICK U. 1- LOOP DROP
  ELSE DROP ." <EMPTY>" THEN CR
;

This works nicely, I suggest it be made available 'out of the box', as it's convenient for interactive use.

@ruv
Copy link
Contributor

ruv commented Mar 16, 2024

In SP-Forth/4, not all standard words are included in the kernel. Some of them are provided in source code files in lib/include/ subdirectory (see also "ANS support" section of the manual in docs/intro.en.md). The word .S is provided in lib/include/tools.f, all the standard words (except locals) can be included via lib/include/ansi.f.

Formally, such approach is allowed by the standard, as the section "3 Usage requirements" says:

A system need not provide all words in executable form. The implementation may provide definitions, including definitions of words in the Core word set, in source form only. If so, the mechanism for adding the definitions to the dictionary is implementation defined.

Nevertheless, the next release plans to provide two binaries — one minimal and one extended with all the standard words and case insensitivity mode by default.

@MaxBarraclough
Copy link
Author

I see, thanks for the reply. I suggest mentioning the following in the README.md to make it easier for dabblers exploring SP-Forth.

S" lib/include/ansi.f" INCLUDED

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

No branches or pull requests

2 participants