-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Should we drop inline if
syntax?
#9765
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
Comments
What is the difference between |
@liufengyun Supposedly, with a good enough constant folder, it could be different is That specific example is not very realistic, but there might other cases where it makes a real difference in practice. |
Another difference between the two is the error message. |
I find I have a little problem reading |
You can write the one that you prefer, there should not be too much difference in practice. The first one will also check that constant folding worked as expected. The point here is that either one will subsume the |
I updated |
This seems to go in the wrong direction of emphasizing the mechanism rather than the intention. With a similar reasoning, we could also argue that Users new to Scala may not understand that We have the |
Inline is only a soft keyword. For example If you which to have a clear differentiation between intent and mechanism, then writing the same a macro would be better. And removing |
In a macro we would have the following code where it is much clearer which parts of the code are executed at compiletime. if n == 0 then '{ ... }
else if n % 2 == 0 then '{ ... }
else '{ ... } |
Actually the intent of an |
We decided to not change this for now. |
Uh oh!
There was an error while loading. Please reload this page.
With the
scala.compiletime.requireConst
in #9764 theinline if
concept becomes redundant.const
trivially subsume all use-cases of inline if with no extra syntactic overheadUsing const has also the advantage of linking to some documentation in the IDE and is more consistent with the other compile-time operations such as
summonInline
.Advantages
scala.compiletime
else if
sDisadvantages
The text was updated successfully, but these errors were encountered: