-
Notifications
You must be signed in to change notification settings - Fork 55
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
Make stream be a subtype of object #434
Comments
Can we also bind from // This is the parameter type of the object:Stream object’s __init method.
type StreamInitFuncParamType abstract object {
public function next() returns record {| ItemType value; |}|ErrorType?;
} |
abstract object {
public function next() returns record {| ItemType value; |}|ErrorType?;
public function close() ErrorType?;
}
;
|
|
Note that #457 also extends @typeparam |
Also relates to #557. |
The |
We need something like |
The typeParam support will not work with the map method in the proposal, Because we can't statically calculate the map method signature using One possible solution is to move such methods to a lang lib module; |
I haven't thought this through yet, but I wonder whether it will be simpler to keep stream as its own basic type, i.e. we postpone this change until we have generics. |
With the original proposal in this issue, it is still the case that So I think it's a viable approach to introduce a lang.stream module to contain this definition (instead of lang.object) and also to contain definitions of functions on streams such as map and reduce. This would require extending the semantics of method call to look up the method in lang.stream when the value is a stream object, and this makes more sense if stream is a distinct object type. This approach will also scale if we want to introduce other types like stream e.g. for event streams #440. But it's still not clear to me whether this is better than keeping stream as its own basic type as now. |
Conclusion was not to do this for Swan Lake and wait till we have generics. |
Another approach would be to define
stream<T,E>
as a predeclared, built-in name for an object type declared in lang.object using a variant of@typeParam
. With this approach,new
would be used to construct streams as normal with objects.lang.object would then include something along the lines of:
Phew!
Originally posted by @jclark in #406 (comment)
The text was updated successfully, but these errors were encountered: