This is the mail archive of the guile@cygnus.com mailing list for the guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: "Magic" Variables?


>> Is there any way in Guile to have special code executed whenever a
>> particular variable is set?

Jim> I tend to feel that such things are an attempt to make notation
Jim> more "cute" than is really a good idea.  If something looks like
Jim> a variable assignment, it should be a variable assignment, not a
Jim> function call.  A programmer shouldn't be wrong if she assumes
Jim> that assignments are idempotent, etc.


Speaking as a long-time Tcl user: variable traces are very handy.
People rarely use them to do complicated things.  Typically you use
them to get state changes propagated through a system.

Also, they are heavily used in Tk so that variables can be used to
represent visual state.  I think this is a particularly nice use for
this feature.

Guile could use some object to represent watchable "variables" in this
same way.  However, for best results you'd want agreement on how this
is going to be done.

Tom
-- 
tromey@cygnus.com                 Member, League for Programming Freedom