Having a match
expression syntax would be useful for inline lookups
#1096
Labels
type: feature
A value-adding code addition that introduce new functionality.
vrl: compiler
Changes to the compiler
vrl: parser
Changes to the syntax parser
vrl: syntax
Changes to the syntax
I am writing some event mapping code that does a number of what are effectively inline table lookups. For example:
I cannot use an object with
get
for this, as sometimes the key is string, integer, ornull
, but objects only have string keys. Also, doing a quick command-line microbenchmark seems to indicate that the above scaffolding is faster than usingget
when the average branch chosen is less than about 7-8 when using strings.It would be handy to have some way of expressing the above as a series of cases, analogous to C's
switch
statement or Rust'smatch
expression:Obviously, in C you can't easily do string matches which would be highly desirable, and Rust's syntax is much more sophisticated than would likely be useful for VRL, so some balance would be desirable.
The text was updated successfully, but these errors were encountered: