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

Add a parameters propert only available in functions which collects all the passed parameters #5739

Closed
filipworksdev opened this issue Nov 7, 2022 · 2 comments

Comments

@filipworksdev
Copy link

filipworksdev commented Nov 7, 2022

Describe the project you are working on

A 3D game

Describe the problem or limitation you are having in your project

I sometimes want to pass multiple parameters to the same functions

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

In a nutshell allow passing any number of attributes/parameters to functions by collecting them into a properties built in parameter which is available only inside functions.

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

Simple example (I know you can use reduce for summing but is just to illustrate what I am proposing)

def add():
  sum = 0
  for v in parameters: # any passed parameters automatically get collected in parameters
     sum += v
  return sum

def _ready():
  print( add(1,2,3,4,5,6,7,8) ) # properties = [1,2,3,4,5,6,7,8]
  print( add(1,2,3) ) # properties = [1,2,3]

If this enhancement will not be used often, can it be worked around with a few lines of script?

Right now It can't easily worked. It can be sort of worked around by using dictionaries or variables.

Is there a reason why this should be core and not an add-on in the asset library?

It would require changes to how functions work

@Calinou
Copy link
Member

Calinou commented Nov 7, 2022

Duplicate of #1034. Feel free to propose your implementation there as a comment, but I think adding global parameters of this kind is a bad idea (see Nim's result out-parameter for an example).

@Calinou Calinou closed this as not planned Won't fix, can't repro, duplicate, stale Nov 7, 2022
@filipworksdev
Copy link
Author

@Calinou Thank you I will do so. I don't think it should be a global parameter either but rather a locally scoped function only parameter.

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