[GUI] [State] Read-only attributes

Vincenzo Ciancia ciancia@cli.di.unipi.it
Sat, 5 Apr 2003 11:50:26 +0200


On Sat, 5 Apr 2003 06:55:28 +0100
Glynn Clements <glynn.clements@virgin.net> wrote:

> 
>  Read-only or write-only attributes could be implemented by throwing
>  an error for prohibited operations. Read-only attributes could be
>  implemented by simply ignoring write operations.

>From now on, I propose to tag messages about state handling with the
[State] keyword, and invite people who are interested in other aspects
of the CGA to start their own discussions.

We could distinguish between two kind of read-only attributes: those
which are fixed at creation-time and those which are written somewhere
and read somewhere else. Apart from this detail, wich is perhaps
unuseful, I think that we should avoid run-time errors when we can model
them in the type system, as it leads to a more detailed machine-checked
specification. 

For the specific case, I like an approach where a state variable has two
components: a read-only one and a write-only one, as in

Variable a = Variable 
   { writeable :: Writeable a, 
     readable :: Readable a }

A read-only attribute is exposed with just the "Readable a" type, not
with the "Variable a" one.

I have to read the other e-mails, and to fit this approach in the
getter/setter one, comments are welcome.

Vincenzo