You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Our existing @typeParam annotation isn't quite powerful enough to capture the type of stream:toArray. It might seem like you could write:
function toArray(stream<Type,ErrorType?> stm) returns Type[]|ErrorType;
But this isn't quite right, because stream<T,error> is a subtype of stream<T,error?>, so this would allow you to pass an unbounded stream. It would also not be right to say:
function toArray(stream<Type,()> stm) returns Type[];
because that wouldn't allow a bounded stream that might return an error.
When the lang library does:
@typeParam
type XType X;
public function foo(XType t) returns XType = external;
X is the upper bound on the type parameter XType i.e. the type parameter can only be instantiated with a type T that is <= XType (i.e. with a subtype of XType). But for toArray what we need is a lower bound on the type, where the lower bound in this case is nil i.e. that it can only be instantiated with a type T such that () <= T. This is a lower bound that is in addition to the upper bound of error?.
So we will need to devise a way to represent that with an annotation in lang lib.
Our existing
@typeParam
annotation isn't quite powerful enough to capture the type ofstream:toArray
. It might seem like you could write:But this isn't quite right, because
stream<T,error>
is a subtype ofstream<T,error?>
, so this would allow you to pass an unbounded stream. It would also not be right to say:because that wouldn't allow a bounded stream that might return an error.
When the lang library does:
X
is the upper bound on the type parameterXType
i.e. the type parameter can only be instantiated with a type T that is <= XType (i.e. with a subtype of XType). But fortoArray
what we need is a lower bound on the type, where the lower bound in this case is nil i.e. that it can only be instantiated with a type T such that () <= T. This is a lower bound that is in addition to the upper bound oferror?
.So we will need to devise a way to represent that with an annotation in lang lib.
Originally posted by @jclark in #453 (comment)
The text was updated successfully, but these errors were encountered: