In this snippet, sequence{} knows its in the `pare...
# getting-started
m
In this snippet, sequence{} knows its in the
parens
rule if you check prop.name in getValue or provideDelegate, but is there a way the resolve() call could get access to this information somehow? I checked the stack trace and couldn't really find anything that could give this information
e
what is
sequence
? that isn't the standard library's
m
This is a custom function in my code, it uses the delegate's name in case of an error and I want to be able to access it in the resolve() calls as well
Turns out you can find the name of the delegate when it's not inlined (sequence being marked as inline) by looking at the class name (in my case
DummyParser$root$2
) but when inlined this is not available (same call:
DummyParser$special$$inlined$sequence$1
)
j
Maybe that would be a case for context receivers.
sequence
could provide this information to nested
resolve
calls
But you could also pass it to
resolve
as a regular argument of course
e
even without context receivers, if you write
fun sequence(block: SequenceScope.() -> Unit)
where
interface SequenceScope { fun Char.resolve() }
, then
resolve
can have access to it as long as you provide it in
SequenceScope
j
Yes, I was assuming the object provided by
sequence
didn't know about resolve. Another option, if this is just for error handling, would be to add a try/catch inside the implementation of
sequence
that wraps exceptions into a higher level one with additional debug information. But that option might not always be possible/suitable depending on how
sequence
runs its lambda