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

Allow skipping of default parameters using named parameters or empty parameters (like C#) #1676

Closed
chucklepie opened this issue Oct 16, 2020 · 1 comment

Comments

@chucklepie
Copy link

chucklepie commented Oct 16, 2020

Describe the problem or limitation you are having in your project:
Pretend you have a method like this:

func start_explosion(
		secs_alive=1.0,
		gravity=55,
                some_count=5
		showdebug=false):

Currently Godot only supports trailing default values. If you want to only override 'some_count', you have to override all of them, e.g.
start_explosion(1.0,55,1000000)

You then lose the ability to use the functions built-in default values. What would be better would be named or optional parameters, e.g.

start_explosion(some_count=100000)
start_explosion(,,,100000)

Describe the feature / enhancement and how it helps to overcome the problem or limitation:
As above

Describe how your proposal will work, with code, pseudocode, mockups, and/or diagrams:
As above

Is there a reason why this should be core and not an add-on in the asset library?:
Optional parameters are a valuable feature of modern languages and a time-saver. Otherwise, you have to resort to using dictionaries and other methods which will be more complex to implement and hinder performance in the same way.

@Calinou
Copy link
Member

Calinou commented Oct 16, 2020

Duplicate of #1034.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants