Two examples I mentioned in a previous post:
-
Need for explicit interface specifications: I could not figure out how to implement the IO interface to solve a simple problem (counting bytes written to a stream).
-
Need for dispatch on interfaces: I wanted to implement a fallback
lastmethod for iterators. The interface is documented, but I can’t definelast(::Iterator). I could not find a backward-compatible solution that dispatches without runtime penalty so I gave up .
Another classical case I think:
-
The
redirect_stdiodocumentation saysredirect_stdout([stream]) -> streamCreate a pipe to which all C and Julia level
stdoutoutput will be redirected. Return a stream representing the pipe ends. Data written to
stdoutmay now be read from therdend of the pipe.Note:
streammust be a compatible objects, such as anIOStream,TTY,Pipe,socket, ordevnull.What does “a compatible object” mean? Impossible to say since there is no definition of a “stream interface”!
This has caused problems when the user wants to capture the standard output to a buffer. The
IOBufferdocumentation says:Create an in-memory I/O stream […]
So you’d think
IOBufferworks withredirect_stdout, but it doesn’t. It’s been reported since 2015 but it’s still an open issue.Probably if there was an explicit specification of the stream interface, this issue would have been easier to fix.