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 bracketed expressions in ZenType declarations. #37

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

eutro
Copy link
Contributor

@eutro eutro commented Oct 23, 2020

This can reduce ambiguity and possibly allow for function arrays, or associatives with function values, if ZenTypeFunctionCallable#toJavaClass ever gets implemented.

This can reduce ambiguity and possibly allow for function arrays, or associatives with function keys, if `ZenTypeFunctionCallable#toJavaClass` ever gets implemented.
Copy link
Contributor

@kindlich kindlich left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm... not sure if I like that you made every array and map type be printed in brackets 🤔

Because people will be confused if it suddenly writes expected (IIngredient)[] what the () are for

@eutro
Copy link
Contributor Author

eutro commented Oct 28, 2020

Without the parentheses, stringifying (function()int)[] would become function()int[], though, which is not the same.

Brackets are a common thing to group expressions, so I don't think people will be too confused, though I'll admit it might look ugly.

@eutro
Copy link
Contributor Author

eutro commented Oct 28, 2020

It might make sense to have ZenTypeFunction stringify including the parentheses instead, since it's the only type where it makes a difference.

@eutro eutro requested a review from kindlich November 11, 2020 22:49
Copy link
Contributor

@kindlich kindlich left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm... I still wonder if we should add these () all the time, or only when needed?

Like, afaik, we only need them for the combination of arrays and functions.

So, thinking:

  • We could have the array's name to only add the () if it's a function
  • We could give ZenType a new method that determines if it needs them.

Sure, an extra set of brackets should not irritate experienced developers.
However, printing the type in another form than that which the user inserted can be irritating to especially new developers.

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

Successfully merging this pull request may close these issues.

2 participants