freenode/#lisp - IRC Chatlog
Search
18:23:12
dmiles
might it be able to be more delcarative like? https://github.com/TeamSPoon/logicmoo_base/blob/master/t/examples/fol/zebra_01.clif
18:27:56
dmiles
well i get tired of seeing myself look at filke dates on code projects as if the date was somehow realivant... so i did that as a joke upon that line of thinking
18:33:43
dmiles
ACTION considered http://nikodemus.github.io/screamer/einstein.lisp.html slightly "too" hand crafted
21:37:59
afiddegnum
hello, i read over and lover lisp macros, can any one explain in a simpler way about them and when to use themn? so far i understand, macros creates executable functions, right ?
21:52:22
no-defun-allowed
Code in Lisp, preferably. Compiler might freak out if you write something like (defmacro define-foo () int foo() { return 42; })
22:09:41
Josh_2
afiddegnum: read "A story of Mac" http://www.gigamonkeys.com/book/macros-defining-your-own.html and the rest of the chapter if you haven't already
22:11:24
aeth
no-defun-allowed: You can actually do infix in s-expressions. (foo 1 + 2 * 3) isn't hard. What you can't do (easily) is -foo... and you certainly can't use ;s since the rest of the line won't be read
22:14:42
aeth
Faking another language directly in macros is discouraged (outside of LOOP), but doable if you don't need a direct syntax match
5:44:52
beach
afiddegnum: Every language has "special forms", i.e. expressions or statements that are not function calls, and that need to be defined by the language. In a C-like language, it might be the assignment, like a[i] = 234, or a conditional, like if (x < 3) fun(x).
5:45:04
beach
In most languages, if you need a special form that doesn't already exist, then you have to wait for the new version of the standard and then for current compilers to implement the new special form. In Common Lisp, you write a macro, that transform the form you want to see (but that doesn't yet exist) into one or more existing form types.
5:45:24
beach
So, for instance, let's say you have a special application that uses Fibonacci numbers a lot. You may wish for a looping construction such as `for each Fibonacci number x do <something>'.
5:45:25
beach
In Common Lisp, you just write a macro for-each-fibonacci-number, that transforms such forms into a TAGBODY and GO that will do the looping. And, in fact, this is precisely the technique used in the built-in Common Lisp macro LOOP.