3 ms·
Yes the lambda issue is something I ran into for Oil. Although this part of the language is deferred, the parser is implemented: # Ruby/Rust style lambda,
by chubot 7y ago
Yes the lambda issue is something I ran into for Oil. Although this part of the language is deferred, the parser is implemented:
# Ruby/Rust style lambda, with the Python constraint that the body can only be an expression
var inc = |x| x + 1
# NOT possible in Oil because | isn't a distinct enough token to change the lexer mode
var inc = |x| {
return x + 1
}
# This is possible but I didn't implement it.
# "func" can change the lexer mode so { is known to start a block.
# In other words, { and } each have two distinct token IDs.
var inc = func(x) {
return x + 1
}
I think this is a decent tradeoff, but it's indeed tricky and something I probably spent too much time thinking about ... the perils of "familiar" syntax :-/