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

Specifying mlog keywords in fucntion calls #215

Open
cardillan opened this issue Feb 1, 2025 · 0 comments
Open

Specifying mlog keywords in fucntion calls #215

cardillan opened this issue Feb 1, 2025 · 0 comments

Comments

@cardillan
Copy link
Owner

Some native functions take a keyword as an argument (e.g. ulocate only accepts ore, building, spawn or damaged as first argument). Current Mindcode syntax doesn't distinguish between such a keyword and an identifier - indeed, these "mlog keywords" aren't even defined as keywords.

Up to now, some hacks were applied in the compiler to get around the issue, but introducing arrays (and variable types down the line) complicates the issue even more. I therefore want to distinguish between mlog keywords and identifiers in the syntax. So far I've come with these possibilities:

  1. Define some specific syntax for keywords. I'm currently leaning towards :keyword, e.g. :ore, but .ore, &ore or any other prefix would also work.
  2. Have a special function turning an identifier into a keyword: keyword(ore). The keyword might or might not be enclosed in spaces.
  3. Create a common enum-style data type and make all keywords be part of it: keyword.ore.
  4. Create a separate keyword enum for each type, e.g. Ulocate.ore, Radar.any and so on.

The last point makes things more organized, but needs to be maintained, and would require yet another mechanism for supporting custom instructions, so I'll probably won't go that way.

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

1 participant