Re: Figuring out easier readonly interfaces

If Foo is a subtype of Bar and you pass a Bar to a function that takes a
Foo, what should happen?

I ask because Foo is a almost an LSP subtype of readonly<Foo>. The LSP
common supertype of Foo and readonly<Foo> has exactly the signature of
readonly<Foo>.


On Wed, Oct 2, 2013 at 6:02 PM, Boris Zbarsky <bzbarsky@mit.edu> wrote:

> On 10/2/13 7:02 PM, Tab Atkins Jr. wrote:
>
>> Okay, so that's a no go in general.
>>
>
> So here's a question.  What set of use cases are we trying to addres?
>
> Defining something where setters have to automatically no-op or throw on
> an object because it's readonly is not too bad.  The complicated thing is
> (mutator) methods.  To address that you have to mark which methods are
> mutators or something.
>
> That then still leaves the question of what happens when you pass a
> readonly<Foo> to a function that takes Foo, I guess.
>
>
>  Interfaces can opt into readonly behavior with a [ReadonlyCapable]
>> extended attribute
>>
>
> Right, this would be explicit opt-ins.
>
> -Boris
>
>


-- 
    Cheers,
    --MarkM

Received on Thursday, 3 October 2013 01:08:34 UTC