-
-
Notifications
You must be signed in to change notification settings - Fork 97
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
Use default value for an argument after ,
#1117
Comments
The problem/limitation discussed is likely the same one as #902. |
This feature might look confusing at a first glance to people coming from other languages. I can't think of any popular language which allows this. |
@Calinou I personally think this is a pretty neat idea, regardless of what other languages do.
|
@SIsilicon Yes, but that |
You can do this in Javascript, but with |
I've also had thaughts about the setget similarity. |
Most people using Godot have experience with at least one other programming language. Breaking expectations means they have to "unlearn" things they've learned in other languages. We'd prefer to keep this to a minimum. For reference, several modern languages like V or Zig are precisely built around this idea. This doesn't mean we should never attempt to add our own things, but we need to weigh the benefits and downsides when doing so. In theory, this feature doesn't hurt so much as you can't accidentally use it. But in practice, I think it looks confusing at a first glance. If you're introducing new Godot developers to your team, they might wonder what's going on when looking at your scripts 🙂 I'm also not sure how often this feature would be needed in practice, especially if we end up getting support for keyword arguments in GDScript. |
I can understand that but if all language programmers would make just little differences to other languages, you could then just not program a new one. |
An explicit keyword is definitely better than just an empty space (I know that So the example would be: my_function(default, "passed to second argument") |
@pycbouh, I agree but what if you have a variable named default? |
Or maybe just a comma would be better if it was highlighted in a strong color? That would be my favourite, I think. |
@MaaaxiKing Keywords are reserved words, you can't name variables using reserved words. You may have a variable named
Code readability should not be dependent on syntax highlighting. |
OK, would be fine then. |
The keyword could be something less likely used for a variable name, like |
Or maybe |
There is already a "keyword" for something similar: |
Oh, you're right. |
@bojidar-bg Arguably not the best syntax either. I'd prefer something that reads obviously in both cases. Makes a bit more sense in |
I think |
,
,
,
I don't see a way to implement this. When calling functions in C++ there's no way to do this, and the binders also don't allow that (maybe could be done with a good amount of hacks but I'd rather not to). So even though I understand the value of this, I don't think it's feasible to implement. |
Closing per @vnen's comment. |
Describe the project you are working on:
Reaction game
Describe the problem or limitation you are having in your project:
I have to give the default value of the first argument if I want to pass a value that is different from the second argument's default.
Describe the feature / enhancement and how it helps to overcome the problem or limitation:
You could step over the argument and only pass a value to the next one.
Describe how your proposal will work, with code, pseudocode, mockups, and/or diagrams:
This would print
vvv
mmm
passed to first argument
ldvm
hshaf
passed to second argument
If this enhancement will not be used often, can it be worked around with a few lines of script?:
I don't think so.
Is there a reason why this should be core and not an add-on in the asset library?:
I think an add-on can't change/add etc. something to the language.
The text was updated successfully, but these errors were encountered: