Rework default value functions & commands #5239
Replies: 2 comments
-
I'm just going to mirror what I said in #5238:
For functions, I think what was suggested in #2993 is a good idea, more readable and more english-like than something like |
Beta Was this translation helpful? Give feedback.
-
Updated my original message to become a bit more clear and also give more input to functions and make it more readable |
Beta Was this translation helpful? Give feedback.
-
After some serious thoughts about how
<type=value>
in commands and functions were brought up about relating to<type=value>
not requiring an optional surrounding[]
placement, I went to talk with ChatGPT while thinking about it and ended up having conversations in #General in SkUnity discord.The term we commonly use for
<type=value>
is DEFAULT VALUE, but this isn't the case for skript as we don't read it as a default value but rather a placeholder value that if the inputted argument is invalid, it returns anull
value instead of thevalue
input.How to go About Changing
If anything, the <type=value> should require the
<=>
to be[<=>]
while this change is relatively hurtful and causes breaking changesthis is the easiest way to define it as a nullable argument explicitly and makes a default value easier to understand
Should
<=>
be changed to work more as a default value? Similar to{_var} ? "Empty"
if the value input is null, we set it to the secondary output, "Empty." Like a placeholder, if an invalid input is included, it will usually return the invalid input as it's technically been defined.By changing the functionality of the placeholder, we create more of a definitive answer to how optionals and default values work while introducing correct terminology to this part of skript.
for those questioning why I mentioned terminology here*
Should we keep the placeholder style of
<type=placeholder>
?Optional:
How about functions?
Functions currently use a similar method to commands; instead of requiring
<>
. They act like it's defined without it existing. However, this led to functions never adding an optional argument selector, and in place, people used placeholder inputs using=%placeholder%
.This had become far too common across files and created many issues when invalid inputs got defined for both required and "optional" arguments.
Skript doesn't check if they're null and instead says "LGTM" and continues forwards. Skript should become more strict with this and introduce an optional tag like
example:?string
, where?
is being used as the equivalent of-
in skript's syntax for nullable. While doing this, we can force NonNullable argumentsexample:string
to stop if the input is null. While still allowing us to doexample:?string="Hello, World!"
Related Issue #5238
Related Conversations https://discord.com/channels/135877399391764480/135877399391764480/1050257575393898617
Beta Was this translation helpful? Give feedback.
All reactions