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

Re: extensions to settor variables?



Arnold Robbins writes:
> I may have mentioned this before on this list.  Ksh-93 takes settor
> variables two steps further.  You can supply functions that are called
> when a variable is a) set, b) referenced, and c) unset.  They are called
> discipline functions in ksh.  The syntax is a bit strange and not worth
> going through here, but is there interest (on Paul's part in particular)
> in seeing something like this in es?

Harald took care of (c) unsetting, but I'll say something on (b)
referencing, or what I'll call getter functions.

There's a bit of a circularity/bootstrapping problem with doing this in
es, since get-foo is a variable as much as foo is, so to get the value
of get-foo one would need to use get-get-foo, and so on.  That's not to
say that some little hack to do the check without a reference when
you're looking up a getter function couldn't be put in place, but it
makes the language a little less clean.

There is no such problem with setter functions, because set-foo only has
to be referenced and not set when setting foo.

By the way, I'm spending the bulk of my time these days working in (and
on) a language (Dylan, if you're curious), where all slot (aka instance
variable, aka member) access goes through getter and setter functions.
My biases say this is a good thing, but I'm not sure it's the right
thing for es.  At least now.

Perhaps it's worth hacking up and trying out for a while.

Paul