quick note on dotty, graaljs interop: structural typing with Selectable
quick note on dotty, graaljs interop: structural typing with Selectable This is a quick note on dotty’s structural typing via Structural and graaljs interop. graaljs is nodejs on the graal vm with interop to JVM. You can run dotty as the JVM language quite easily, just like any other JVM language. Dotty has a new feature for structural typing ( https://dotty.epfl.ch/docs/reference/changed-features/structural-types.html ) based on the Selectable trait. It implements a dynamic lookup to values based on application specific metadata. The example given on the web site is: case class Record ( elems : ( String , Any ) * ) extends Selectable { def selectDynamic ( name : String ) : Any = elems . find ( _ . _1 == name ) . get . _2 } type Person = Record { val name : String val age : Int } val person = Record ( "name" - > "Emma" , "age" - > 42 ) . asInstanceOf [ Person ] println ( s ...