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
I found a concrete use case today where I could use intersection types (type-intersection).
Assume that:
I have a class <file-descriptor> which wraps an integer file handle.
I have bindings for read, recv, recvmsg, etc. I want them to operate on a readable file descriptor.
I have bindings for write, send, sendmsg, etc. I want them to operate on a writable file descriptor.
Most file descriptors will be both readable and writable.
I model the readable and writable states as mixin classes: define class <readable-mixin> (<object>) and define class <writable-mixin> (<object>).
These can not inherit from <file-descriptor> as it would create an invalid inheritance hierarchy.
I don't want read / write and friends to only take the mixin class as an argument, because if I do that, then getting the raw file handle will be a generic dispatch.
It seems like being use an intersection type here would be useful:
It is valid to get file descriptors that you know are read-only, so it would be nice to be able to signify that at the type system level. But I also wanted to be able to specify readable / writable for a more complicated reason within the posix-sockets binding which then led to thinking about all of this.
The text was updated successfully, but these errors were encountered:
I found a concrete use case today where I could use intersection types (
type-intersection
).Assume that:
<file-descriptor>
which wraps an integer file handle.read
,recv
,recvmsg
, etc. I want them to operate on a readable file descriptor.write
,send
,sendmsg
, etc. I want them to operate on a writable file descriptor.define class <readable-mixin> (<object>)
anddefine class <writable-mixin> (<object>)
.<file-descriptor>
as it would create an invalid inheritance hierarchy.read
/write
and friends to only take the mixin class as an argument, because if I do that, then getting the raw file handle will be a generic dispatch.It seems like being use an intersection type here would be useful:
It is valid to get file descriptors that you know are read-only, so it would be nice to be able to signify that at the type system level. But I also wanted to be able to specify readable / writable for a more complicated reason within the
posix-sockets
binding which then led to thinking about all of this.The text was updated successfully, but these errors were encountered: