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

Predicate dispatch



>From the various Goo documents Cecil is listed as being an influence on
some Goo ideas. Cecil has the ability to create predicate objects. An
example from the Cecil documentation is:

---------------8<---------------
For example, predicate objects could be used to implement a bounded
buffer abstraction: 
  object buffer isa collection; 
    field elements(b@buffer); ญญ a queue of elements 
    field max_size(b@buffer); ญญ an integer 
    method length(b@buffer) { b.elements.length } 
    method is_empty(b@buffer) { b.length = 0 } 
    method is_full(b@buffer) { b.length = b.max_size } 

  predicate empty_buffer isa buffer when buffer.is_empty; 
    method get(b@empty_buffer) { ... } ญญ raise error or block caller 

  predicate non_empty_buffer isa buffer when not(buffer.is_empty); 
    method get(b@non_empty_buffer) { remove_from_front(b.elements) } 

  predicate full_buffer isa buffer when buffer.is_full; 
    method put(b@full_buffer, x) { ... } ญญ raise error or block caller 

  predicate non_full_buffer isa buffer when not(buffer.is_full); 
    method put(b@non_full_buffer, x) { add_to_back(b.elements, x); } 

  predicate partially_full_buffer isa non_empty_buffer,
  non_full_buffer; 
---------------8<---------------

Goo has some predicate-type types (singleton, union, product, etc). Is
or will there be the ability to define other types to emulate something
like the Cecil example above?

Chris.
-- 
  Chris Double
  chris.double@double.co.nz