-
-
Notifications
You must be signed in to change notification settings - Fork 384
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
DefaultOperations.java - Add blank string default #7712
base: dev/feature
Are you sure you want to change the base?
DefaultOperations.java - Add blank string default #7712
Conversation
I personally prefer defaulting to null instead of an empty string. If users want an an empty string as a default, they can explicitly specify ( |
I believe this proposal aligns well with Skript’s goal of being user friendly, especially for those without programming experience. The current behavior of string concatenation seems like an oversight, as when stringifying a null variable it would output |
I think this is a good spot for runtime errors to be used. I don't think adding unset values should work in general, but the behavior of null = 0 in math has been grandfathered in, sadly. I don't think that's worth changing at this point. I think that any invalid operation (string + number, string + null, null + timespan, ...) should return null and produce a runtime error. It's the most explicit and clear way to handle ambiguous or nonsensical math. |
I feel like Skript should match its parent language... java. I haven't really done much in other languages, but I'd assume they're similar. |
I agree with Shane |
I think this would be fine if skript were a typed language, but given the nature of variables being any type, this could result in unintentional string concatenation. I think enforcing "%%" is a better idea to make it clear you want it as a string, similar to python's |
In my opinion, having a mismatch between "%%" v. concat seems a little confusing and super inconsistent. |
Can you elaborate on what you mean by mismatch? I'm not sure what you're referring to |
|
Gotcha. I think there's two ways to approach this currently: I personally think a) is the safest approach for skript, but I have certainly found it a little unintuitive, especially after using java (I feel the same with python, so this isn't necessarily saying java's way is the best, only that skript's is different from java's). I would be ok with b) if it's able to be implemented safely without affecting any other types of math (I have no clue if this is the case or not), though. |
I don't see why it couldn't. If Java can do it, other than SkriptLang team saying no... what's stoping this behaviour?
If we look at Java's
You saw how well that worked when I added them in SkBee for empty NBT 😂 .... people are going to hit the fan when they get runtime errors. b) Same as mentioned above. Just wanted to finish off with again... I think there (like Java) should be consistency between insertion and concat. |
I wouldn't really call Java the parent language of Skript. it's just what skript is written in, for better or worse. This is not too different from saying "I feel like Java should match it's parent language... C++" just because most JVMs are written in C++. |
My statement (maybe worded incorrectly) is referencing the fact that Skript is going to be limited to what Java can/can't do.... but also being the fact it's written in Java, Skript should share some consistencies. |
@ShaneBeee I think you misinterpreted the formatting of my message a bit. A) and B) were two design decisions you can choose to follow. Of course, you can coerce a world into a string, that's what java does. But if you are using the design decision that string concatenation should not coerce types, then you cannot concatenate a world with a string. As far as format, yes, that's string insertion. Python has a similar formatting method, but doesn't allow concatenation of differing types. Similar behaviors vary wildly across langauges, so I don't think we should base choices on what a specific language does or doesn't do, but rather how that choice affects the end result in Skript. Runtime errors here I think would work fine. The case with SkBee is that they were overused (imo) and often triggered in scenarios that users deliberately intended. In this case, any invalid operation will already result in a failure state and return none, which i think is a great place for an error. I don't envision a situation in which the desired result of any math operation is none, hence I think that an error fits well here. |
Just going with general talk, I'm fine not doing I can agree to sending an error when someone does I would be a little confused on how to add the error as I'm still not great at understanding runtime errors due to lack of any documentation for implementation. |
I talked with Shane a bit more on the skriptlang discord about this and I think there's 2 routes that could be good here:
I'm ok with both routes, though I think I would prefer the more extensive changes as I've definitely tried to use + for concatenation and wanted to have it coerce objects into strings automatically. |
Since my brain is not yet working at full functionality, does this mean we're good with adding a String + Object then? Since the quoted part mentioned |
Yes string + object only is safe imo. I don't know what others think of that, though. |
So I presume |
There's no consensus yet, so no. |
If someone wants this behavior, I would prefer to see them use
I see the desire to have string + object, but I don't think it is worthwhile when we already have perfectly fine and more explicit tools available for this. |
actually, I guess ExprJoinSplit doesn't support objects like the broadcast expression. Adding that could be a way forward, but I do have concerns about how that might change how existing code is parsed. Interestingly, it does have |
As for your example, I agree it's unintentional but it's also a pretty easy mistake to find the source of, in my opinion. Currently, that code would simply not send anything and that's harder to figure out and fix. Of course, with runtime errors that gets fixed. My take is that it's worth it to take that small idiosyncrasy in return for a much more flexible string builder. |
shouldn't it parse error since the argument return type is known? |
Oh true, my mistake. Imagine a named argument instead, then. |
Yeah it would be hidden in that case. The last thing I'd point to is that javascript has this behavior, and I think it is pretty widely considered to be a not great thing |
Yeah that's also my main argument against it. I think we would have to accept that kind of ambiguity in some cases, but we effectively already do with things like timespans and dates also having math operations. It's already unknown what {_a} + {_b} is really doing until runtime. I think that Skript's semi-typing in the form of needing types for function parameters and commands also helps clarify what's going on a bit to the reader, which all adds up to basically a big shrug. I think it's enough to tip the scales towards having the usefulness of string + object over sticking with a slightly less ambiguous addition operator for me. I also wonder about adding a config-suppressible warning when a string is added to, say, a literal number. It may be worth it to introduce people to the concept if they didn't realise it worked like that at first. |
perhaps we can sit on it for a month or two and see how it feels then? I don't think this is needed so urgently that we can't take a moment to be intentional about our decision |
Technically speaking, anything new added into Skript isn't urgent unless to fix a major bug.
Can you explain what you mean by this? You want the current debate to just end and pick back up in a month or two? Regardless of your intention by this, seems like poor behavior. Why hold off the debate that is happening? Especially when we all know when the 1 or 2 month time is up, you will still dislike this idea. |
I agree!
Yeah, I just mean that there's no need to go super quickly. We can take a moment to let the idea set and revisit in a few months, no big deal. I've had plenty of things I've added in the past (especially early on) that I think could have really benefited from stepping back and intentionally take some time. On another note, your replies can often make me feel as though I am being perceived as an "enemy" in some fashion. I would really appreciate if you could give me the benefit of the doubt. I really have a limited energy for contributing to Skript these days, and I promise I only still do it at this point because I care about the language and the community. It can be really frustrating when I spend some of this limited energy on trying my best to engage politely and fairly, and then someone replies in a way that feels as if my words are being received in a manner that assumes I have some ulterior motives. We are all just volunteers here, and I know you care about the language too. Please, let's work together on that common goal 🙂❤️. |
My fear with sitting on this too long is, it skips a "major" update, skripters get used to this odd behaviour and 1 of 2 things happens:
I am by no means pushing for this to be done tomorrow, but it would be nice if a consensus could be decided upon before the 2.11 reason on (or around) April 1st. It seems like the consensus to allow |
It's not really about that this needs to be decided ASAP. It's that things labeled as
I know that you don't have ulterior motives. The one thing I do know is that when you make up your mind, you don't change it. Which can be proven through the multiple suggestions that have been created since January where you have disagreed and labeled as
The only "enemy" I would consider you to be is against quality of life and useful additions towards the users, that actually use Skript, that could benefit from said additions. |
I am not sure something like this is necessarily going to make it into 2.11 even if we start implementing it today, just with the amount of time left. I could be wrong, but the changes made to ExprArithmetic I did to make a prototype were not super trivial and I'd want a good set of tests and at least a review by tud before being confident with it. It definitely could make it, but I don't think we should rush discussion just for the sake of 2.11. I don't think we need to take a month or whatever but I would like the input of more team members, especially at least another core maintainer to chime in. |
Yeah, we can certainly continue to talk about it however I do feel aiming to get this in for 2.11 is a jumping the gun a bit. Skript is pretty unusual in how it handles changes like this because there is no formal proposal process like you find in other languages. Above all, I think the most important thing we can try to deliver to Skript users is stability and predictability. I think it's best for Skript's long term health if we pause for a moment before changing fairly fundamental aspects of the language (like the behavior of an operator). The conversation doesn't have to stop in the meantime! This PR has only been open for two days - in my eyes, it would be great to allow others the opportunity to chime in with their perspective or to point out things we may have missed. Since I don't think we should get it in for 2.11, I'd love to target the end of April instead. If the consensus at that point is that we want it, that's totally fine with me. That's just about a month and a half, which is pretty much lightspeed as far as language proposals are concerned. |
Thank you for this reply. |
I'm not sure we need to put any specific date on this, since I fear it's rare for discussions to start back up after people have said their piece, but I do agree that it's been open for a very short time and there is a need for more voices before we make any decisions. I suppose having the end of april is at least some sort of deadline but I don't think we need to necessarily wait until then if we get some more thoughts in the next week or two. |
Description
This PR aims to add a new operations default of
""
when someone does"example" + {_unset}
The issue this is related to is marked as "Up for Debate", however from my perspective I see no harm in skript handling null with blank.
I will mark this PR as draft, until a decision is firmly made by the team, any other feedback is welcome
While it's true in java
"blank" + null
throws a null point exception, there's also work arounds likeObjects.toString()
andString.valueOf()
, I think there's more benefit from this over none.If the main concern is someone does
{_blank} + "Hello"
and doesn't correctly handle their variable, then I believe having the ability to actually see the string missing their inputted type makes more sense than it abruptly becoming null especially in scenarios where they're doing"This " + {_that} + " and this"
an error in their code is clearly visible and debuggable.Target Minecraft Versions: any
Requirements: none
Related Issues: #6917