3 ms·
You can configure (read) to be safe for this purpose. It’s not a hack.
by groundzeros2015 3mo ago
You can configure (read) to be safe for this purpose.
It’s not a hack.
- pfdietz 2mo agoYes, there's a specific standard special variable controlling it, *read-eval*.
- groundzeros2015 2mo agoYou can also configure a read table to disable any other data structure features you want. inb4 DoS attack. That is a universal parsing problem and should be solved by configuring OS limits for your process.
- pfdietz 2mo agoI'm of two minds about read tables. Yes, it's nice we have control over it. This is a lisp thing, where features that are used to implement standard things (like the standard reader) are exposed so the user can play with them also. But code written with custom read tables has some problems. Different code with different read tables may not be composable. If I have two packages that use incompatible read tables I can't import them into a third package and expect to be able to use their readtables there. Also, it makes treating code as an object to be inspected, modified, and written out again difficult. This is similar to the problem of code rewriting systems on preprocessed languages like C or C++. A different branch of Lisp put everything into S expressions. Interlisp, for example, had comments in the code as forms, so the code could be editted as S-expressions. But that was dropped from Common Lisp, which took the surface syntax more from Maclisp.
- groundzeros2015 2mo agoGood points. I sometimes see it as “easy and clean json” rather than code as data.