contravariant argument types: wanna?
Steven Schveighoffer
schveiguy at yahoo.com
Thu Sep 24 10:09:53 PDT 2009
On Thu, 24 Sep 2009 12:47:12 -0400, grauzone <none at example.net> wrote:
> Steven Schveighoffer wrote:
>> The solution we ended up using is that *all* streams defined the seek
>> function, even if they didn't support seeking, and if you called it on
>> such objects, they just throw an exception.
>
> So, if you want to see if an object supports seeking, you must call the
> method + catch the exception? How is this better than a dynamic cast?
It makes the requirement for things that want to wrap streams less
stringent. For example, I can implement a Buffer that handles both
seekable and non-seekable streams instead of 2 buffer types.
It also has less of a penalty for cases where you know the stream is
seekable.
-Steve
More information about the Digitalmars-d
mailing list