Hello again :)
I just wanted to create a class Logger which has some subclasses (e.g. NoOpLogger that does nothing, ConsoleLogger that logs to console, FileLogger etc.). Because there are no static methods and with that the ability to make a singleton object I've handed the object through those classes that needs logging. Then I noticed that if I just specify that the type must be Logger or a subclass of it that always the log(...) procedure of the superclass Logger were invoked, thus it seems to be not possible to shadow a proc with a variable number of arguments?
I've written a short example that should illustrate my problem:
1 class Logger {
2 proc log(args ...?k) {writeln("Logger#log ...");}
3 }
4
5 class ConsoleLogger : Logger {
6 var lock$ : sync bool = false;
7
8 proc log(args ...?k) {
9 lock$;
10 write("---", here.id, "--- --> ");
11 for param i in 1..k {
12 write(args(i));
13 }
14 writeln();
15 lock$ = false;
16 }
17 }
18
19 var consoleLogger : Logger = new ConsoleLogger();
20 consoleLogger.log("hello");
2 proc log(args ...?k) {writeln("Logger#log ...");}
3 }
4
5 class ConsoleLogger : Logger {
6 var lock$ : sync bool = false;
7
8 proc log(args ...?k) {
9 lock$;
10 write("---", here.id, "--- --> ");
11 for param i in 1..k {
12 write(args(i));
13 }
14 writeln();
15 lock$ = false;
16 }
17 }
18
19 var consoleLogger : Logger = new ConsoleLogger();
20 consoleLogger.log("hello");
Output: Logger#log ...
--> the implementation in the superclass Logger.
Kind regards,
Marco
------------------------------------------------------------------------------ Dive into the World of Parallel Programming. The Go Parallel Website, sponsored by Intel and developed in partnership with Slashdot Media, is your hub for all things parallel software development, from weekly thought leadership blogs to news, videos, case studies, tutorials and more. Take a look and join the conversation now. http://goparallel.sourceforge.net/
_______________________________________________ Chapel-bugs mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/chapel-bugs
