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 support for varargs in datatype definitions #19

Closed
talios opened this issue Dec 6, 2015 · 5 comments
Closed

Add support for varargs in datatype definitions #19

talios opened this issue Dec 6, 2015 · 5 comments

Comments

@talios
Copy link
Contributor

talios commented Dec 6, 2015

Would be it possible to add support for varargs:

interface Cases<R> {
  R develop(Job job, Job... dependencies);
  R review(Job job, Job... dependencies);
}

generators constructors like:

public static JobType develop(Job job, Job[] dependencies) {
...

It would be handy if the constructor method matched the vararg definition.

@jbgi
Copy link
Member

jbgi commented Dec 7, 2015

Arrays are painful to work with. I see how varargs can be useful in the constructor signature but I don't think anyone would want to work with them when pattern matching on the datatype. plus that would mean the datatype is mutable...
In your example I think you would be better of using a datatype like NonEmpty<T> that may already provide the varargs constructor.

@talios
Copy link
Contributor Author

talios commented Dec 8, 2015

True - was more just thinking having the consistency would be nice. Maybe a warning emitted if you happen to use varargs?

The code in question I ended up switching for a javaslang HashSet which ended up making the code cleaner in the end as well for other reasons.

@jbgi
Copy link
Member

jbgi commented Dec 8, 2015

I agree that consistency is important, will have a look at it.

@jbgi jbgi added this to the 0.6 milestone Dec 29, 2015
@jbgi jbgi closed this as completed in 61bb0ed Dec 29, 2015
@jbgi
Copy link
Member

jbgi commented Dec 29, 2015

I also fixed some non compiling code in generated hashcode/equals/toString in presence of arrays.

@talios
Copy link
Contributor Author

talios commented Dec 30, 2015

Awesome :)

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