freenode/#lisp - IRC Chatlog
Search
10:08:23
luis
madrik: well, you can go back if the upgrade broke your software, or you can have different software on different versions of the quicklisp distribution
11:57:08
drmeister
Xach: We've been running a "quickclasp" server to distribute stuff specific to clasp - it's been working well.
12:30:59
nij
Anyone knows how to use this library? In particular, how to use #'digit? to parse a digit? https://github.com/Ramarren/cl-parser-combinators/blob/9c7569a4f6af5e60c0d3a51d9c15c16d1714c845/token-parsers.lisp
12:59:31
splittist
nij: you mean beyond (parse-string* (seq-list? (digit?) (digit?) (digit?)) "123") ?
13:05:57
nij
Cool. It works. Next is to try to learn how it's implemented.. I feel like it's more advanced than my level.
13:16:02
splittist
Built in? I don't know. As a general parsing lib it must be able to if set up. I guess you'd define atom? (or whatever your language requires) then match on an open paren, any number of sexps and a close paren. Not quite like this: (parse-string* (bracket? #\( (sepby? (int?) #\Space) #\)) "(1 2 3)")
13:21:11
nij
Many articles I read about lisp only says that macro helps you create DSLs a lot easier.
13:25:21
beach
nij: Macros are useful for introducing "syntactic abstractions", i.e., new syntax. You don't need macros if you can express your DSL as a collection of functions with normal function-call semantics. And in cases like that, you can write your DSL in any language you like.
13:27:24
nij
I see. That's my impression yeah. I don't see why macros and DSLs are tided together so much.. at least in many introductory articles.
13:29:55
lotuseater
yes, they can take anything and transform it :) or when you just not want having to type in so much quotes
13:32:29
lotuseater
or eg look at FORMAT, it's a function, that calls the macro FORMATTER, which takes the control-string and transforms that to the corresponding form for using the args
13:34:00
beach
nij: The use of macros to implement a DSL in Common Lisp would be used precisely to make the syntax less Lisp-y. If you want Lisp syntax, just use Common Lisp.
13:35:57
pjb
beach: in general. But in the case of format, it could be used to make it lispier :-) (format (formatter "Name: (a :width 20) Age: (d :width 3) year(p :with-previous-arg t)(newline)") 'john 99)
13:44:36
pjb
nij: but you can pass your own formatting function to format instead of a format control (format t (function my-formatter) a b c)
13:45:12
pjb
format control n. a format string, or a function that obeys the argument conventions for a function returned by the formatter macro. See Section 22.2.1.3 (Compiling Format Strings).
13:53:06
pjb
the trick of the formatter macro, is to let the macro generate the function itself, from a new description of what is to be formatted.
13:54:14
splittist
(defun printformatter (control-string) (lambda (stream &rest args) (apply #'printfcl:fprintf stream control-string args))) (printformatter "%d %d %d") (format t * 1 2 3) => 1 2 3 (: