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

<automatic common sharing field>



I've added <common sharing field> that works like `:allocation :each-subclass slot' of CLOS.

Example:

(define color 'white)
(define-lambda-object cpoint
  (a 1) (b 2)
  ((,,color) color)
  (`,area (* a b)))

(define a (make-cpoint))
(map a '(a b color area)) => (1 2 white 2)
(define b (make-cpoint 3 4))
(map b '(a b color area)) => (3 4 white 12)
(a 'color 'black)
(map a '(a b color area)) => (1 2 black 2)
(map b '(a b color area)) => (3 4 black 12)
(b 'color 'blue)
(define c (make-cpoint 5 6))
(map a '(a b color area)) => (1 2 blue 2)
(map b '(a b color area)) => (3 4 blue 12)
(map c '(a b color area)) => (5 6 blue 30)


The specification is changed as follows:

(define-lambda-object <group spec> <field spec>)

<group spec> --> <group> | (<group> <parent group>*)

<parent group> --> <group>   ;unamendable group
         | (<group>)   ;amendable group

<field spec> --> <required field>* <optional field>* <automatic field>*

<required field> --> <field>   ;read-only field
       | (<field>)   ;read-write field

<optional field> --> (<field>  <default>) ;read-only field
       | ((<field>) <default>) ;read-write field
     | ('<field> <default>) ;inaccessible hidden field

<automatic field> --> (,<field>  <default>) ;read-only field
         | ((,<field>) <default>) ;read-write field
      | (',<field>  <default>) ;inaccessible hidden field
      | (`,<field>  <default>) ;immutable virtual field
      | (,,<field> <default>) ;common read-only field
      | ((,,<field>) <default>) ;common read-write field



--
Joo