-
-
Save ojow/2c7ec2683ca2c78ca27756740c151a56 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// for a REPL/worksheet session | |
class Ctx { println("ctx created") } | |
type Expr = given Ctx => String | |
case class ExprContainer(e: Expr) | |
def createContainer(e: Expr) = ExprContainer({ print("."); e}) | |
delegate for Ctx = new Ctx | |
def anExpr: Expr = { println("expr runs"); "a" } | |
createContainer(createContainer(createContainer(anExpr).e).e).e | |
val a: Expr = createContainer(createContainer(createContainer(anExpr).e).e).e | |
createContainer(a).e | |
type OldExpr = Ctx => String | |
case class OldExprContainer(e: OldExpr) | |
def createOldContainer(e: OldExpr) = OldExprContainer({ print("."); e}) | |
def anOldExpr: OldExpr = { println("expr runs"); _ => "a" } | |
createOldContainer(createOldContainer(createOldContainer(anOldExpr).e).e).e | |
val oldA: OldExpr = createOldContainer(createOldContainer(createOldContainer(anOldExpr).e).e).e | |
createOldContainer(oldA).e |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment