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

Foldable parameters #1820

Open
lerno opened this issue Jan 12, 2025 · 3 comments
Open

Foldable parameters #1820

lerno opened this issue Jan 12, 2025 · 3 comments
Labels
Discussion needed This feature needs discussion to iron out details Enhancement Request New feature or request Loose idea Probably will not be included in the language, but documented to allow discussion

Comments

@lerno
Copy link
Collaborator

lerno commented Jan 12, 2025

enum Foo : (int val)
{
   ABC = 123
}

struct Baz
{
  int x;
  double y;
}
    
fn int my_function(Foo.val f) 
{
  int y = f * f;
  return y;
}
fn double my_function2(Baz.y d) 
{
  double y = d * d;
  return y;
}

...
int x = my_function(ABC); // passes the value 123
Baz b = { 4, 1.5 };
double y = my_function2(b); // y = 2.25
@lerno lerno added Enhancement Request New feature or request Discussion needed This feature needs discussion to iron out details labels Jan 12, 2025
@vssukharev
Copy link
Contributor

Seems like really weird syntax for structures. We don't want to implicitly cast structure object to one of its members.

@alexveden
Copy link
Contributor

Not worth it, makes code unclear. IMO

@Book-reader
Copy link
Contributor

I think this could end up kinda like ref parameters where there are so few uses that it is better to just remove them and replace them with something simpler like inline enum values, which are the only thing I can really see them being used for

@lerno lerno added the Loose idea Probably will not be included in the language, but documented to allow discussion label Jan 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Discussion needed This feature needs discussion to iron out details Enhancement Request New feature or request Loose idea Probably will not be included in the language, but documented to allow discussion
Projects
None yet
Development

No branches or pull requests

4 participants