3 ms·
Very useful post I think. Not to depreciate Python the language, but it might be interesting to compare "adding a new statement to Python" with "adding a new st
by perfunctory 15y ago
Very useful post I think. Not to depreciate Python the language, but it might be interesting to compare "adding a new statement to Python" with "adding a new statement to Lisp". Especially for people struggling to grasp Lisp's benefits.
- davidw 15y agoOr adding a new statement to Tcl: http://wiki.tcl.tk/917 http://wiki.tcl.tk/917
- gaius 15y agoOr BASIC ;-) http://en.wikipedia.org/wiki/DOS_Wedge http://en.wikipedia.org/wiki/DOS_Wedge On a more serious note, the ability to add constructs to the language is not nearly as unique to LISP as Lispers think it is.
- gaius 15y agoOr Forth. http://www.yosefk.com/blog/my-history-with-forth-stack-machines.html http://www.yosefk.com/blog/my-history-with-forth-stack-machi... my mind was immediately blown away by the following passage right at the top of system.fth, the part of pForth implemented in Forth on top of the C interpreter: : ( 41 word drop ; immediate ( That was the definition for the comment word. ) ( Now we can add comments to what we are doing! )
- Kototama 15y agoHere, adding a 'unless' statement: (defmacro unless [expr & body] `(if ~expr nil (do ~@body))) Taken from: http://stackoverflow.com/questions/2977882/defining-clojure-macro-syntax http://stackoverflow.com/questions/2977882/defining-clojure-... Macro in Lisp are essentially functions taking code as argument and returning code, but they are executed at compile-time. Edit: replaced with the correct version, sorry for the error.
- roryokane 15y agoAccording to that question's answer and comments, that definition is buggy (making it not quite a fair comparison). Here is a less buggy, more flexible version, taken from a comment: (defmacro unless [expr & body] `(if ~expr nil (do ~@body)))
- draegtun 15y agoOr Io: unless := method(call evalArgAt(0) ifFalse(call evalArgAt(1))) Usage example... unless(1 == 2, writeln("Tis false"))