-
Notifications
You must be signed in to change notification settings - Fork 162
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
Use opaque types for Scala 3 #592
Conversation
object IDBTransactionDurability { | ||
@inline def default: IDBTransactionDurability = "default" | ||
@inline def strict: IDBTransactionDurability = "strict" | ||
@inline def relaxed: IDBTransactionDurability = "relaxed" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any reason for some of the constants to be @inline def
s instead of val
s? It seems that it would be nicer if all of them were val
s, doesn't it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed, I'll take a pass through and clean these up.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah that's me, or if it wasn't me, that's something I do. My reasoning is that it reduces unnecessary bytecode. If they're val
s they're always present in the output JS (so long as the object is instantiated), where as with def
s unused fields can be omitted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, that's a good point. I think the advantage of val
s is that they are stable and can be used for match
ing, but not sure how much use that is here. Happy to go either way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any way these get inlined e.g. if they are final val
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Btw: just noting that if a future release of Scala.js gets some kind of purity checking it will be able to remove unused vals from the output too. It wouldn't even need to be complex to detect cases like this. @sjrd: I'm might just ping to put it back on your radar :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you used inline val
you would also end up with no field in the bytecode.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good to know, can we still make this change binary-compatibly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know well enough how binary-compatibility works in the Scala.js world so I can't say :).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know well enough the behavior of inline val
in terms of compilation scheme so I can't say :).
We'll have to try.
Closes #587. Note: basing against #588 for now.