-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Change syntax of given whitebox macros #8619
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
|
Or |
I actually like the Reg. trying to replace
|
The problem is that: inline def foo : ? <: String is very different semantically from: inline def foo : List[? <: String] The latter is not whitebox at all, even though it uses a very similar syntax. |
Hm, you may be right and it may be too cute. How would the keyword syntax look? Like this? inline whitebox def foo : String = … |
|
The part that I am slightly miffed about is that we would lose the "this is not an actual type annotation" suggestion that the current syntax |
I'd go for |
How about ? inline def whiteBox1 : ?String
inline given whiteBox2 as ?T = ...
This was propose and rejected for |
Finally, I have always thought that this feature deserved a flag. We currently have no way to know if an inline method is whitebox or not after it is typed. |
Scala 2 accidentally treats an empty refinement as "do not widen" indicator. Could we make that official and use it here, inline def foo : String {} ... |
We should have a syntax where not widening would not happen by mistake. |
I am not sure about the flag. We are currently trying hard to reduce the number of flags that we pickle. Even without a flag., there could be a robust predicate on symbols indicating whether an inline function is blackbox or whitebox Namely, an inline function inline def f(): T = rhs is blackbox if transparent inline def f(): T = E: T that also gives a blackbox macro according to our definition, despite the |
Why though? That sounds like a useless target metric. What's important is to pickle the semantics of the language, and not a particular encoding of the language. It should add simple as possible, sure, but not simpler. You can argue that the semantics of blackbox macros is a whitebox macro with an ascription. But then that's also how you have to specify the language. And that means that you cannot explain blackbox macros without explaining whitebox macros. That doesn't seem like a good deal to me. |
Note that we will need as a flag (or at least in the TASTy file) for #7825. |
Fix #8619: Demand `transparent` for whitebox inlines
What I had in mind was a method |
Here's the ruleset:
That means we can treat whitebox/blackboxity without having to change the Tasty format. The Tasty format remains smaller, which is a win in my book. It also removes some magic from the inlining. Otherwise we'd have to specify differences of inline expansion for blackbox and for whitebox macros. One gets its type widened on expansion, the other does not. By pushing it all into desugaring (ascribe or not) we avoid this added complexity. |
Uh oh!
There was an error while loading. Please reload this page.
Status quo
Critique
whiteBox1
is in the position where you would expect to see a type._ <: T
is technically wrong (or, rather, old style) since it suggests a lambda. We are after an existential instead.Proposal
Write
? <: T
(analogous to a wildcard type argument) to express both forms of whitebox macros. I.e.Opinions?
The text was updated successfully, but these errors were encountered: