3 ms·
I've read this article a few times and every time he takes beef with Python: x + (if is_true(): 1 else: 2) I think he just got he syntax wrong, it's suppose
by i_am_proteus 7y ago
I've read this article a few times and every time he takes beef with Python:
x + (if is_true(): 1 else: 2)
I think he just got he syntax wrong, it's supposed to be:
x + (1 if is_true() else 2)
And basically can't follow the rest of the argument. I have yet to learn a Lisp. Honestly, what am I missing?
- z3phyr 7y agoThe macro system
- memling 7y ago> The macro system To add a little more detail to a spare but correct (I think) comment: Outside of Beautiful Racket, some other helpful reading I've found in the past that covers macros: > Creating Languages in Racket (Matt Flatt, 2011, ACM Queue) [0] The details here are tantalizing, but there's a lot that goes unsaid. Code is available for download and review. As a longer-form example of something fun to do, it's good, and I've enjoyed it. > Automata using Macros [pdf] (Shriram Krishnamurthy, date unk., Educational Pearl) [1] This is a worthwhile read at only 14 pages. Krishnamurthy writes with clarity, iterating through several solutions to writing a finite state automaton. [0]: https://queue.acm.org/detail.cfm?id=2068896 https://queue.acm.org/detail.cfm?id=2068896 [1]: http://cs.brown.edu/~sk/Publications/Papers/Published/sk-automata-macros/paper.pdf http://cs.brown.edu/~sk/Publications/Papers/Published/sk-aut...
- z3phyr 7y agoThank you. Although it is against the norms of HN, I deliberately did not go on writing an explantion of the Macro system, because in my experience, I did not fully understand it's power until I used common lisp. Before that, I thought of the macro system to be like the #define preprocessor in C, nothing more. Thank you very much, for actually expanding it with great links!!
- jbotz 7y agoThe point of the "if" example is that there is a difference between expressions and statements... yes, Python has a conditional expression (since Python 2.5, before it didn't), but it had to be a different syntax for that reason; the "if" expression is a completely different thing than the "if" statement (it's what's sometimes called a "ternary conditional") it just happens to use the same keywords (but without the ":"). In LISP everything is an expression, the syntax is totally uniform.
- i_am_proteus 7y agoInteresting, and thank you for the explanation!