guile-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Smart variables, dumb variables


From: tomas
Subject: Re: Smart variables, dumb variables
Date: Wed, 14 Aug 2002 10:07:15 +0200
User-agent: Mutt/1.3.24i

On Tue, Aug 13, 2002 at 10:06:50PM +0200, Marius Vollmer wrote:
> Hi,
> 
> currently, our global variables are strictly passive containers.

[...]

> I would add a 'flags' field to variable smob (there is room for it),
> with the following flags defined initially:
> 
>    - SCM_F_VARIABLE_DUMB 
> 
>      When set, the variable is 'dumb' and can be referened and set
>      with SCM_DUMB_VARIABLE_REF and SCM_DUMB_VARIABLE_SET,
>      respectively.  When it is not set, you need to call
>      scm_variable_ref and scm_variable_set_x.
> 
>    - SCM_F_VARIABLE_READONLY
> 
>      When set, the variable can not be set.  You are not allowed to
>      use SCM_DUMB_VARIABLE_SET and scm_variable_set_x will result in
>      an error.

An attractive idea, indeed. Let's see whether there are objections
from the `language theorists' out there.

I'd propose a slight modification, though: use one flag for the setter,
one for the getter, like so:

   - SCM_F_VARIABLE_DUMB_GETTER

     When set, the variable has a `dumb' getter and can be
     referenced with SCM_DUMB_VARIABLE_REF. Otherwise you
     need to reference it with scm_variable_ref.
     
   - SCM_F_VARIABLE_DUMB_SETTER

     When set, the variable has a `dumb' setter and can be
     referenced with SCM_DUMB_VARIABLE_SET. Otherwise you
     need to set it with scm_variable_set_x.

It looks more symmetric ;-) and it's still possible to implement `unsettable'
variables (by appropriately implementing a setter function which does nothing,
complains, whatever seems appropriate). I think it's even more flexible.

Regards
-- tomas




reply via email to

[Prev in Thread] Current Thread [Next in Thread]