You can declare identical functions, with the first one apparently taking charge: fun void g(int i) { <<< "fddf" >>>; } fun void g(int i) { <<< "fdfd" >>>; } g(3); I have a feeling this is old news, but I can't recall this specific issue being mentioned. It doesn't feel right. It's the same if the functions are inside classes. Could it have something to do with enabling cross-shred referencing? Cheers, Stefan -- Release me, insect, or I will destroy the Cosmos!
On 24 Jan 2010, at 23:20, Stefan Blixt wrote:
You can declare identical functions, with the first one apparently taking charge:
fun void g(int i) { <<< "fddf" >>>; }
fun void g(int i) { <<< "fdfd" >>>; }
g(3);
By contrast, return types can't differ, for some strange reason: fun int g(int i) { <<< "fddf" >>>; } fun float g(float i) { <<< "fdfd" >>>; } produces: function signatures differ in return type... In C++, I recall this is so for polymorphic functions, as then the argument selects which function copy to use at runtime, and it isn't possible to let the static return type vary. That is, in ChucKish pseudocode fun int h(T); // Declaration. g => h; // g is some of the copies above. h(...) => s; // Syntax is statically checked, so s must be at most a polymorphic that // can hold all possible return values of h. But that is not possible in ChucK yet.
I have a feeling this is old news, but I can't recall this specific issue being mentioned. It doesn't feel right. It's the same if the functions are inside classes. Could it have something to do with enabling cross-shred referencing?
It's likely a bug. Or how would that enable cross-shred referencing? Hans
participants (2)
-
Hans Aberg
-
Stefan Blixt