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

Locales and Objects

Consider the parallels between locales and objects, and
identifiers and operations.  Locales are associations
between identifiers and values.  Objects are associations
between operations and procedures specified by the method
of the operation in the object.  If one is willing to limit
values to procedures, one can simulate an environment with
an object as follows:

(let ((env (make-locale <parent> nil)))
  (*define env 'a (lambda args ....))
  (*define env 'b (lambda args ....))
  (*define env 'c (lambda args ....)))


(define-operation a)
(define-operation b)
(define-operation c)
  (object nil
	  ((a . args) ....)
	  ((b . args) ....)
	  ((c . args) ....))

and lookups correspond:

((*value env id) . args)	=>  (operation object . args)

While older versions of T had mutable object handlers 
which allowed the modification of methods without the 
evaluation of the entire object definition, the current 
documentation suggests this is not allowed.  Thus a
difference between locales and objects as environments 
is that dynamic update of the object implementation of 
an environment is not allowed.

Some people have suggested that locales as first class 
data items is a bad idea as it allows introspective 
programs (Brian Smith's thesis is on introspective 
programs).  I claim that if objects are allowed to
have mutable handlers as they are in ZetaLisp's Flavor 
system, they are susceptable to the same criticism.