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

What additional restrictions, if any, should be applied to functions which use positional parameters? #3860

Open
CJ-Johnson opened this issue Apr 4, 2024 · 3 comments
Labels
leads question A question for the leads team

Comments

@CJ-Johnson
Copy link
Contributor

Summary of issue:

In addition to the proposed restrictions (definition must be attached to the declaration; only one function in an enclosing scope can use positional parameters), an additional restriction was considered. That being, visibility of functions with positional parameters could be restricted to only non-public interfaces. What do the leads think about this candidate additional restriction?

See Lambdas proposal at #3848

Details:

No response

Any other information that you want to share?

No response

@CJ-Johnson CJ-Johnson added the leads question A question for the leads team label Apr 4, 2024
@justzh

This comment was marked as spam.

@Hira-Iftikhar-123
Copy link

Summary of the problem with restriction on Public visibility:
this is beneficial as the restriction could help enforce good design practices, encouraging developers to use more explicit and self-documenting parameter passing methods, such as named parameters or data structures

Proposed solution:
The solution is to provide clear guidance and examples which could help developers to understand the reason of restriction and they can therefore, adhere the best practices of parameter passing.

Here are some alternative strategies or patterns that achieve the same goals without imposing such a strict limitation.

1- By encouraging the use of named parameters.
2- By promoting the use of data structures.
3- By providing clear guidelines and examples.
4- By considering gradual adoption.(by gradually applying restrictions.)

@chandlerc
Copy link
Contributor

My stance on this is that we should try out the minimal set of restrictions and see what happens. I feel like we can easily tighten these rules later if useful, and it seems somewhat interesting to leave the flexibility technically in the language.

Put differently, I wonder if whether to use this technique in a public API will end up being more of an HOA rule than a building code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
leads question A question for the leads team
Projects
None yet
Development

No branches or pull requests

4 participants