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/
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
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
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
Greetings! "pure" is short for "pure virtual", which is similar to method prototypes in Java interfaces, abstract Java methods, or pure virtual functions in C++ (denoted by the "= 0" at the end of a member function declaration). This feature is, not surprisingly, not yet fully implemented in ChucK. Mostly, the motivation for "pure" is so you can end up with function declarations that start with the string "pure fun". The dangers of name-driven research... Ge! On Sat, 9 May 2009, Robert Poor 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"...)
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
_______________________________________________ chuck-users mailing list chuck-users@lists.cs.princeton.edu https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
And I guess you could expand "fun int" into something like "fun,
in't?" which probably only sounds right if you've been hanging out
some drunk Brits.
andy
2009/5/10 Kassen
Ge;
Mostly, the motivation for "pure" is so you can end up with function declarations that start with the string "pure fun".
Yay! We think alike; I still feel that "fun void" must refer to a sort of casual, lighthearted nihilism.
Yours, Kas.
_______________________________________________ chuck-users mailing list chuck-users@lists.cs.princeton.edu https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
Andrew, And I guess you could expand "fun int" into something like "fun,
in't?" which probably only sounds right if you've been hanging out some drunk Brits.
That might be it but I look at "int" functions as being more analytical types (clearly they are INTelligent) and the "float" ones as more hippy-ish fellows. I'm not sure what "dur" functions are like, maybe I don't typically have too many of those for that reason. Perhaps we also need to have "progressive" functions to offset the static ones? At least Function Character Theory confirms that sproking is a bit naughty, with only the nihilistic (and so not believing in objective and universal morality) void functions doing it. At least it's clear that they are all fun so it's all good. Kas.
On Sat, May 9, 2009 at 4:48 PM, Andrew Turley
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;
a.doit();
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
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 http://AllTom.com/
participants (5)
-
Andrew Turley
-
Ge Wang
-
Kassen
-
Robert Poor
-
Tom Lieber