gluon
gluon copied to clipboard
Ergonomic way to use Gluon type parameters in Rust
With #600 you replaced most uses of Generic
with for example OpaqueValue<RootedThread, generic::A>
. Is this always necessary? If so it's probably best to make this more convenient to use (and maybe also hide some of the internals like all of the generic::*
enums).
I unfortunately had to change how Generic
worked to make sure it was always safe to use which forced me to modify it. Before the next release I want to go through this whole api again though to further generalize and simplify these parts though but for the moment just using OpaqueValue<RootedThread, generic::A>
should always work (you may want to define a type alias over it though).
and maybe also hide some of the internals like all of the generic::* enums
Not sure what you mean, the A
,B
... enums under generic
are all meant to be part of the public api as it makes it possible to use multiple type variables in the same function.
(You can still use Generic
as a parameter at least but it is currently awkward to use as an output)
Still a WIP but #607 is the rough idea.
For instance, it makes it possible to write array.index : Array a -> Int -> a
entirely with rooted values https://github.com/gluon-lang/gluon/pull/607/files#diff-17448a895470d132de007f9f3c5bb485R28
Looks really neat!
Does that mean you can use OpaqueRef<'a, generic::A>
for parameters instead of Generic
? In that case it's probably better to remove Generic
completely. OpaqueRef
seems more consistent to me, and it's a lot easier to understand why you need a wrapper in first place.
Yep, that's the idea. I have already removed it in that PR and I will likely be able to remove a few more such wrappers as well.
Will explain it in the book after I am done as it should be an API I can actually feel good about stabilizing