On Sun, 15 Feb 2004, Luke Palmer wrote: > As with Perl 6. A sub object has a C<do> trait which specifies what > to do when it's called.
Cool. > But I think findmethod is a good idea, cross-language-wise. Each > language has a different idea of what a method is, and they can > store it that way. As long as findmethod is vtableable, you can > hook it up to whatever system your language uses. I was thinking the same thing as I wrote my post last night... But I'm not convinced. Suppose I do something like this: x = parrot.find("perl::whatever") x.method() Is that second line a method call or a function call? It depends whether x is an object or not. Now maybe in SOME cases (no dynamic input) a compiler could be smart enough to tell for python... But how could I ever know cross language? How will the compiler know to emit findmethod here rather than getproperty? I would suggest that since perl and python both work this way, this is the way it should work for parrot. If a language happens to let you do something like: class MultiAttribute { x : int = 2; method x() { return 1; } } Then getattr(x) should return some kind of smart attribute that knows how to evaluate to 2 if it's used as an int or 5 if it's called. And what about this? class MultiMethod { method x(a:int) { return a+1; } method x(a:str) { return 200; } } Which x does the get? or does my compiler have to be smart enough to look at the arguments that get passed in? I submit that's impossible to determine, too: args = input("enter arguments") foo.multimethod(*args) I think all methods for all languages should act the perl/python way for this reason. Or at least all languages that want to talk to each other should emit getprop (or something like it) and then if the property is invoked, it should be called just like a normal function. If it needs a magic "self" variable or does some kind of dispatch based on the arguments, then that should be handled internally by the method PMC. In fact, since I'm on the subject, properties and attributes also have this problem. If we want our languages to work together there should be one and only one type of "slot" on an object. It should be up to the PMC itself to determine how that works internally. If a more static language has objects that are all the same size and wants attributes instead of properties then it should handle that internally. The interface should be the same either way. Sincerely, Michal J Wallace Sabren Enterprises, Inc. ------------------------------------- contact: [EMAIL PROTECTED] hosting: http://www.cornerhost.com/ my site: http://www.withoutane.com/ -------------------------------------