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"...) As an aside, I appreciate the value of "programming by contract" constructs. - Rob On 9 May 2009, at 13:48, Andrew Turley 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.
andy
On Sat, May 9, 2009 at 12:38 PM, Tom Lieber
wrote: class X { fun void doit(); }
[Untitled]:line(2): function declaration must contain code... [Untitled]:line(2): (unless in interface, or is declared 'pure') [Untitled]:line(2): ...at function 'doit'
interface X { fun void doit(); }
[Untitled]:line(2): function declaration must contain code... [Untitled]:line(2): (unless in interface, or is declared 'pure') [Untitled]:line(2): ...at function 'doit'
class X { fun pure void doit(); }
[chuck](VM): sporking incoming shred: 1 (Untitled)...
Does anybody use "pure" or know what it does? The last example seems to be equivalent to saying "fun void doit() { }".
-- Tom Lieber http://AllTom.com/ _______________________________________________ chuck-users mailing list chuck-users@lists.cs.princeton.edu https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
_______________________________________________ chuck-users mailing list chuck-users@lists.cs.princeton.edu https://lists.cs.princeton.edu/mailman/listinfo/chuck-users