Just curious, what lisp is good for and what lisp is not the best choice?
-
-
-
It's particularly good for exploratory programming, meaning when you're solving problems you don't understand yet. (Which actually is most programming.) It might not be so good for very low-level C-type programming where you're manipulating specific bytes in memory.
- Show replies
New conversation -
-
-
In what circumstances is it better to use a macro v using a function ?
-
You should only use a macro to do something you can't do with a function.
End of conversation
New conversation -
-
-
i've always liked this first example from https://www.braveclojure.com/writing-macros/ pic.twitter.com/jOqWHSLBxO
Thanks. Twitter will use this to make your timeline better. UndoUndo
-
-
-
Not quite hello world, but one of my favorite beginner macros, to demonstrate the power of lisp, is nullthrows. Helps grasp the concept that the argument is the ast
-
(defmacro nil-throws [form] `(let [result# ~form] (if (nil? result#) (throw (ex-info "uh oh, we got nil!" {:form '~form})) result#)))
End of conversation
New conversation -
-
-
I just started learning Lisp & found this helpful to understand macros (.clj -> .cl): (defmacro echo (e) `(progn ,e ,e)) This takes one argument and “runs” it twice. > (echo (format t "hello ")) hello hello NIL in contrast: > (defun…) (PROGN NIL NIL)https://stackoverflow.com/questions/3667403/what-is-the-difference-between-defn-and-defmacro …
Thanks. Twitter will use this to make your timeline better. UndoUndo
-
-
-
@paulg what about this macro? (defmacro pass-args (code &rest args) `(,@code ,@args)) It takes one argument and “applies” it to the others. > (pass-args (format) t "Hello, World!") Hello, World! NIL > (pass-args (+) 1 2 3) 6 Thanks for the challenge! https://gist.github.com/jorgezaccaro/55cb80fdf939586db58a450c0d87a1a9 … -
Can you give an example where you use this macro to write something that would be inconvenient to write without it?
- Show replies
New conversation -
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.