0

Is it possible?
I tried something like this:

object foo extends Foo {
    constructorNamedArg = "qqq";
} {
    abstractMethod() => bar.baz();
}
guai
  • 780
  • 1
  • 12
  • 29

2 Answers2

4

I would not use inheritance for this. Instead I would define Foo as a concrete class:

class Foo(String constructorNamedArg, Baz abstractMethod()) {}

And now at the call site I would write:

Foo {
    constructorNamedArg = "qqq";
    abstractMethod() => bar.baz();
}

Or even:

Foo {
    constructorNamedArg = "qqq";
    function abstractMethod() { 
        return bar.baz(); 
    }
}

It's a common refactoring in Ceylon to go from abstract class with formal methods to concrete class parameterized by functions.

HTH

Gavin King
  • 3,182
  • 1
  • 13
  • 11
1

According to the specification, it is not possible, there can be only positional argument list.

Paŭlo Ebermann
  • 73,284
  • 20
  • 146
  • 210
thradec
  • 106
  • 2
  • 1
    How can one create a internal dsl in ceylon? Probabely using the Tree-syntax. Beyond that, syntactic improvements like a monadic for syntax would be very desirable in ceylon, e.g. for trampolining, since ceylon not even does tail recursion right. That requires to introduce new variables which is not possible using Tree-like syntax. What is the best way to work around that shortcomings in ceylon? –  Dec 22 '15 at 12:50