Closed tjvr closed 7 years ago
@nathan
getValue
? :-)Is this a good idea?
Instinct says "function calls are slow", but it's probably fine. We're not forcing anyone to use it.
Can you suggest a better name than
getValue
? :-)
These come to mind:
{ getValue: x => x.slice(1, -1) } // for comparison
{ value: x => x.slice(1, -1) }
{ transform: x => x.slice(1, -1) }
Okay. I'll go with value
. :-)
Okay. I'll go with
getValue
. :-)
It appears you went with value
?
That was what I meant to say, oops. :P
Now that we've dropped capturing groups, adding some sort of
value
transform seems more compelling. Of course, you can currently do this outside Moo; but where multiple rules have the sametokenType
but different match patterns, we can't tell--from outside Moo--which transform to apply!Together with #62, this allows us to have different rules with the same token type, but different rules and transform functions. Motivating example:
(In practice you'd also want to handle backslash escapes inside your
getValue
function.)Surprisingly, this doesn't seem to hurt perf too bad.
diff