Creating DSL in Scala 3

I am trying to create a DSL in scala 3. I was looking for reference when I found this https://github.com/kmizu/dotty-tree/blob/master/src/main/scala/Main.scala

I want something very similar. However this is 3 years old syntax for dotty. A lot has changed and it doesn’t compile with Scala 3.0.0-M2. Could someone please help me understand what would the following line look line in version 3.0.0-M2

def table(init: implicit Table => Unit): Table

Ok, I found out about context functions. So the syntax is:

def table(init: Table ?=> Unit): Table
1 Like

That is quite different.

The first one receives an implicit function as an argument (which is quite weird TBH).
The second one receives an explicit function but whose first parameter is implicit as an argument.

Not really,
Earlier as well, it had a function as input parameter who’s argument is implicit. The function itself is not implicit.

def table(init: implicit Table => Unit): Table

it was

init: implicit Table => Unit

and not

implicit init: Table => Unit

Ah sorry, I got confused.

I thought the original code was Scala 2 and looked quickly looked over it.

1 Like