I would love if languages like Scala, Swift or F# had something like Cel but running at compile time so your program was evaluated against those restrictions. I believe a language called Idris has something like this
I would love if languages like Scala, Swift or F# had something like Cel but running at compile time so your program was evaluated against those restrictions. I believe a language called Idris has something like this
Are you suggesting to compile CEL into native code and run the compiled code at runtime (i.e. as a predicate function)? I think this is doable and I vaguely remember this was how it's implemented initially.
But most use cases are treating CEL as a user provided config, which requires runtime parsing and execution.
I was thinking of something like this:
type MyType{ myName: string where size > 8, year: number where number > 2000 }
Then, whenever this type is used, at compile time, an evaluation is done to ensure that the type restrictions are enforced.
A better solution would be first-class metaprogramming, like in Zig or LISP. Maybe with some subset which guarantees to halt (I.e. no unbounded loops, no recursion, no FFI, known input size, hard time limits, etc.)