Is there a more fluid way to tame scoping of givens? #12529
liufengyun
started this conversation in
General Discussion
Replies: 1 comment
-
As a workaround, I ended up with something like the following: def use[T, R](v: T)(op: T ?=> R): R = op(using v)
def eval(e: Expr): Contextual[Value] =
...
use(trace :+ e) {
use(env2) {
eval(fun.body)
}
} With indented-syntax, it looks better: def use[T, R](v: T)(op: T ?=> R): R = op(using v)
def eval(e: Expr): Contextual[Value] =
...
use(trace :+ e):
use(env2):
eval(fun.body)
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I am writing an interpreter-like program:
In the code above, the following two lines are problematic:
Two problems:
given Trace = trace :+ e
will run into cycleseval(arg)
in the same scope, a forward reference again.As a result, I am forced to break the definition of
given Trace = trace :+ e
into two lines and using a block:But what I really want is something like the following:
The hypothetical construct
given T = rhs in e
is supposed to fix two scoping problem:given/in
in the same blockrhs
Beta Was this translation helpful? Give feedback.
All reactions