3 ms·
I'm confused by this. I've never written Clojure or Lisp. I'm a run-of-the-mill C#, .NET developer. But even I am used to treating LINQ expressions as bot
by emorning3 3y ago
I'm confused by this.
I've never written Clojure or Lisp.
I'm a run-of-the-mill C#, .NET developer.
But even I am used to treating LINQ expressions as both code and data.
I can take a LINQ expression, modify it if I want, compile it, and execute it against a given runtime context.
I would have expected this duality between code and data to be intrinsic to Clojure.
Hence my confusion.
- codr7 3y agoC# isn't really my cup of tea, but from what I know about LINQ; I'd say that's code, not data. You couldn't put that expression in a database, read it back and interpret it without some serious hoop jumping. The lines get blurry in Lisp, since the code is explicitly encoded as a data structure (tree).
- barrkel 3y agoLINQ expression trees can be serialized with a custom serializer, but it's a mistake to do so for a different reason: deserializers which materialize code or substitutes for code are major vulnerability vectors. Anyone who has had to upgrade Jackson or remove naive pickling will be familiar.
- neonsunset 3y agoArguably, as long as you don’t allow specifying arbitrary types in the serialized format, it should be safe as you can’t otherwise construct gadgets to produce unexpected side effects.
- emorning3 3y agoI'll concede your point about saving LINQ in a database. But you know what I can do, in a day... Take a rule, written as a function in C#, compile it to an assembly, save it in a database with a name and checksum, and then dynamically load it later when I want to execute it. ta daaaaaa..... :-)
- emorning3 3y agoI take that back, I'd still write a LINQ expression, and compile and save that in the db. That way I can display the original rule as text to a user and let them modify it. ta daaaaaa...