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

Reserve variable starting characters. #6609

Open
wants to merge 5 commits into
base: dev/feature
Choose a base branch
from

Conversation

Moderocky
Copy link
Member

Description

In an upcoming version, we're looking at instituting new special variable types (e.g. unsaved, reference).
No plans are finalised for this, but the first step is reserving the starting characters (like _ for local variables).

The current characters reserved are:

{~variable}
{.variable}
{$variable}
{!variable}
{&variable}
{^variable}
{*variable} # See note 2
{+variable}
{-variable} # See note 1

Currently, this will only issue a warning when they're used (but it won't prevent anything loading).
Presumably, in some future version, this will become an error (or the variable will have some special functionality)!

Why these characters?

It was a pretty arbitrary choice, we just picked a handful of special characters to give us some freedom for future changes.

Note 1: - minus variable

A lot of people use the (?!-).* pattern in the config to prevent {-variable} from being saved at all (i.e. to vanish when Skript terminates).

We'd like to institute proper behaviour for an 'ephemeral variable' in the future (rather than just using the config pattern as a patchwork), so that's why we're reserving this character.

However, I've tried to skip the warning IFF you're using this pattern in the config (since there's nothing to warn you about).

Note 2: * star

Stars are already prohibited in variable names (other than in a list::*) so this one shouldn't affect anybody.


Target Minecraft Versions: any
Requirements: none
Related Issues: none

@Moderocky Moderocky added enhancement Feature request, an issue about something that could be improved, or a PR improving something. variables Related to variables and/or storing them. labels Apr 25, 2024
Copy link
Member

@sovdeeth sovdeeth left a comment

Choose a reason for hiding this comment

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

maybe we could add a suppression option but i don't mind either way

@Moderocky Moderocky added the 2.10 Targeting a 2.10.X version release label Aug 20, 2024
@Moderocky Moderocky marked this pull request as ready for review September 4, 2024 09:15
Copy link
Member

@APickledWalrus APickledWalrus left a comment

Choose a reason for hiding this comment

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

These are generally my own thoughts, so please feel free to counter back

}
}
Skript.warning("The character '" + token + "' is reserved at the start of variable names, " +
"and may be restricted in future versions");
Copy link
Member

Choose a reason for hiding this comment

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

It appears that tabs and spaces are being mixed on this line. Two standard indents should suffice

Copy link
Member

@APickledWalrus APickledWalrus left a comment

Choose a reason for hiding this comment

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

Looks good. I have a small request

continue check_reserved_tokens;
}
}
Skript.warning("The character '" + token + "' is reserved at the start of variable names, " +
Copy link
Member

Choose a reason for hiding this comment

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

I would like to see this message in english.lang. I think it is reasonable for us to provide translation support for these internal messages.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2.10 Targeting a 2.10.X version release enhancement Feature request, an issue about something that could be improved, or a PR improving something. variables Related to variables and/or storing them.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants