[chuck-users] "pure"

Tom Lieber lieber at princeton.edu
Sat May 9 19:29:38 EDT 2009

On Sat, May 9, 2009 at 4:48 PM, Andrew Turley <aturley at acm.org> wrote:
> If I didn't know any better (and I don't) I would guess that calling a
> method "pure" is a way of indicating that any class that implements X
> must provide a function called "doit()", but that X will not provide a
> default implementation of that method. It forces the child class to
> provide the implementation.
> If you wrote:
> class X {
>   fun void doit() {};
> }
> and then created a class Y that extends class X, Y would not have to
> provide an implementation of "doit()". Take a look at pure virtual
> classe in C++, interfaces in Java, or abstract classes in general.
> One of the uses for pure function is to help with "programming by
> contract" where other methods and functions will accept objects that
> are guaranteed to provide *some* implementation of a method, without
> making any claims about what that method will do.

That all makes sense, but ChucK runs this code:

class X {
    fun pure void doit();

class Y extends X {

Y a;

It's not documented, so maybe it's just half-way to what you said...

On Sat, May 9, 2009 at 5:15 PM, Robert Poor <rdpoor at gmail.com> wrote:
> I need to know: How did Tom find out about the "pure" keyword in the first
> place?  By consulting the "authoritative documentation" [i.e. chuck_type.cpp
> :)]?  Is reading the source code the only way to learn about these things?
> (Ditto for "interface"...)

Well, inspired guessing from the error message "(unless in interface,
or is declared 'pure')"

Tom Lieber

More information about the chuck-users mailing list