Hi all,
This is the proposal to change the default unbox configuration, currently:
type t = A (int)
type t = {a : int}
These are boxed by default, to unbox it, it requires the attribute @unboxed
.
I am planning to change the default behavior so that we have unboxed by default, and the user has to add @boxed
attribute to preserve the old behavior. (Note that @boxed
attribute is not a new attribute, it already exists there)
The major motivation is not for performance, but for the convenience of some special encoding. For example, we have rank-2 polymorphism with records:
@unboxed
type t = {
id : 'a . 'a => 'a
}
It will also make Avoir cyclic function when returning itself? - General - ReScript Forum (rescript-lang.org) easier, with unboxed by default, it can be written as is:
type rec func<'a, 'b, 'i> = ('i) => result<'a,'b,'i>
and result <'a,'b,'i> = Val (('b, func<'a, 'b, 'i>))
Let me know if I miss anything, thanks – Hongbo