|
|
On 8/14/2012 7:16, Invisible wrote:
> Well, you're right in that you cannot write any code which explicitly
> expects Bar. You can pass the result to any function that works with /all/
> types, or any function that works with any showable type. If the module
> exported some functions that expect Bar as input, you can pass the result to
> them. But you can't write that in a type signature, which... yeah, is a bit
> silly.
That's what I was saying. You can't return type Bar if you haven't made it
exposed. You can declare that foo returns a Bar, but you can't actually use
Bar. It gets the equivalent of being upcast to "object" or to whatever
interface you've defined it to be. So the fact that you can't return an
opaque Bar is no hinderance - declare foo to return the appropriate
interface or Object.
> My point wasn't so much that this is a something anybody is likely to want
> to do. My point was a counter-example to the "that's obviously impossible"
> argument. It's /not/ impossible at all.
By that reasoning, it's possible to do it in C#:
return (Object) Bar;
return (Showable) Bar;
--
Darren New, San Diego CA, USA (PST)
"Oh no! We're out of code juice!"
"Don't panic. There's beans and filters
in the cabinet."
Post a reply to this message
|
|