[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Predicate dispatch
"Chris Double" <chris.double@double.co.nz> writes:
> >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?
yes and no. there is the beginnings of an extensible type protocol
but up til now one guiding goo (and dylan) type system tenet has been
that an object's type membership is determined at object creation
time. so while we hope to go beyond dylan in terms of creating a more
flexible type protocol (with some of the nice properties of predicate
types, including unification), we have not yet worked out how to
elegantly and efficiently extend goo to incorporate some of the
wackier sides of predicate types and dispatch. obviously, it's doable
and perhaps desireable, but the devil lies in the details.
greg sullivan and i advised a master's student, aaron ucko, on a
predicate dispatching in CLOS thesis. we can make this available to
interested people.
jonathan