ELENA-LANG / elena-lang

ELENA is a general-purpose language with late binding. It is multi-paradigm, combining features of functional and object-oriented programming. Rich set of tools are provided to deal with message dispatching : multi-methods, message qualifying, generic message handlers, run-time interfaces
https://elena-lang.github.io/
MIT License
236 stars 26 forks source link

Auto generating multi-method default handler with type casting #521

Closed arakov closed 1 year ago

arakov commented 4 years ago

When there is only single variant of multi-method, the autogenerated multi-dispatcher should typecast the value to expected types

E.g. in the following code:

public interface Glyph
{
    abstract draw(Window w);
}

The default implementation should be auto.generated, to be equivalent to:

public interface Glyph
{
    abstract draw(Window w);

    draw(o)
        <= draw(cast Window(o));
}
arakov commented 4 years ago

When types are known in compile-time it should inject typecasting and call it directly

arakov commented 1 year ago

resolved