3 ms·
How can control structures be implemented with JSON, though?
by itmag 15y ago
How can control structures be implemented with JSON, though?
- lloeki 15y agoThe same as in LISP. Code being data and data being code, an 'if' is a function that merely returns/evaluates either second or third argument based on first argument evaluation. Reminds me of this tiny LISP: http://www.brool.com/index.php/the-tiniest-lisp-in-python http://www.brool.com/index.php/the-tiniest-lisp-in-python
- arethuza 15y agoLispish: ( if ( > a b ) 'foo 'bar ) JSON: [[ "if" [ ">" a b ] "foo" "bar" ] If you are writing code then I'd go for the Lisp approach, for general purpose data then these days I'd go with JSON.
- joesb 15y agoAnd how can that S-EXP control structure be usable in all other scripting language beside Lisp? If you can answer this question then you have already answered your own question. But if your answer is "I don't have to because I use Lisp and I don't use other languages" then you miss the point of JSON.