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

case-insensitivity for [if] #12

Open
ruv opened this issue Aug 22, 2024 · 5 comments
Open

case-insensitivity for [if] #12

ruv opened this issue Aug 22, 2024 · 5 comments

Comments

@ruv
Copy link

ruv commented Aug 22, 2024

ciforth version 5.5.1

It seems, [if] [else] [then] are still case-sensitive even though "CASE-INSENSITIVE" WANTED.

The command:

echo '0 [if] 1 . [else] 0 . [then]' | ./lina64 -f ' "AUTOLOAD" WANTED  "CASE-INSENSITIVE" WANTED CR '

Prints nothing instead of 0.

Actual output:

 "AUTOLOAD" WANTED  "CASE-INSENSITIVE" WANTED CR
[if] : (WARNING) NOT PRESENT, THOUGH WANTED
 WANT [if]

Expected output:

[if] : (WARNING) NOT PRESENT, THOUGH WANTED
 WANT [if]
0
@ruv
Copy link
Author

ruv commented Aug 22, 2024

If ciforth provides the standard word wordlist, a reference implementation for [if], [else], [then] can be used.

@albertvanderhorst
Copy link
Owner

albertvanderhorst commented Aug 29, 2024

It cannot be argued that the supplied solution is non-standard, because [THEN] is not supposed to be a Forth word. It violates the principle of least surprises, though. All uses of [IF] are a mine field, anyway and I will not recommend it. I'll put this matter in the FAQ.

@ruv
Copy link
Author

ruv commented Aug 29, 2024

Yes, if you say that the system supports the case-insensitive mode, the user expects that the words [if], [else], [then] can be used in lower case too. Why not implement this?

@ruv ruv changed the title case-insensitiviry for [if] case-insensitivity for [if] Aug 29, 2024
@albertvanderhorst
Copy link
Owner

albertvanderhorst commented Aug 31, 2024 via email

@ruv
Copy link
Author

ruv commented Aug 31, 2024

I don't want to promote conditional compilation by [IF] where WANTED is more superior, anyway.

That's fine, no problem.
JFYI, WANTED does not help in portable code when you check what words are available and use different implementations depending on that. For example, if the system provides find-name, you use find-name, otherwise you use find.

[THEN] is not a dictionary word

There is a [THEN] word. See 15.6.2.2533 [THEN].

You must get used to it that [THEN] will be recognized in comment and strings.

This is irrelevant to the initial problem.

Anyway, yes, you cannot wrap a string literal in [IF] [THEN] if that string literal contains the substring "[THEN]" or "[IF]". This is by design. The same problem exists in many programming languages. For example, in C, you cannot wrap a string literal in a multi-line comment if that string literal contains "*/". The same in Forth multi-line comments.

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