User loginNavigation |
archivesbodyf*ck: an esoteric programming environment using camera inputA product of critical programming language design. Abstract:
Expletives stared out because I'm a coward. By Sean McDirmid at 2014-03-13 03:51 | LtU Forum | login or register to post comments | other blogs | 4248 reads
Multimethods over structural typesHello, I am interested to know if there are languages out there, or research projects, or people's wild private imaginings, that provide polymorphic multimethods over structural types. I mean the non-parametric type of polymorphism where methods may have > 1 implementation. The dispatch mechanism would choose the most specific of those available for a given invocation. I have found one mention of something that seems in this area, but I don't understand the paper enough to know if it's what I hope for: Combining Structural Subtyping and External Dispatch I'm not _even_ a language design noob, and have only recently found there is established terminology ("structural types") for what I've been edging towards for about 10 years. But… I envisage that the dispatch mechanism would be able to examine implementations of a method for the signature they require of their arguments. Given a method invocation is would be able to find the most specific implementation given the types, or fail if there is no match or the match is ambiguous. I also think that a kind of transitive closure is necessary here. I'll use an example to elucidate (the example is "single dispatch", btw):
def area(shape) # implementation 2 def width(shape) def height(shape) I can now evaluate: area( {radius: 1} ) area( {square_size: 2} ) Implementations's parameters are not decorated with explicit type declarations because the type an implementation needs for each of its arguments _are_ the methods it calls on those arguments. So, if this kind of thing is going on all over the place and well known, I'd love to know. Or if it's been tried and found a terrible idea, that'd be good to know too :-) I find the possibility enormously exciting because I think it'd "fix" an awful lot of what I find rather hobbling about the languages I generally use. Especially if it could be embedded in some kind of live-coding environment. Thanks, |
Browse archivesActive forum topics |
Recent comments
22 weeks 3 days ago
22 weeks 3 days ago
22 weeks 3 days ago
44 weeks 4 days ago
48 weeks 6 days ago
50 weeks 4 days ago
50 weeks 4 days ago
1 year 1 week ago
1 year 5 weeks ago
1 year 5 weeks ago