freenode/#lisp - IRC Chatlog
Search
9:55:18
aeth
I wonder where optimizations fit. These are especially key when you have a minimal command language where you're supposed to compose things. One case would be +++++ which in a hypothetical simple language taken literally would mean (progn (incf x 1) (incf x 1) (incf x 1) (incf x 1) (incf x 1)) but can be optimized to (incf x 5)
9:55:34
aeth
It seems like this kind of thing could be done at either the lexer or the parser, and would complicate even a seemingly simple language.
9:57:57
beach
The role of the lexer and that of the parser are often blurred. In most real languages, a lexer is in fact not possible as a first step. It has to know the context as defined by the grammar. Also, there are parsing techniques that do not need a lexer at all.
10:29:58
White_Flame
aeth: generally the parser does not optimize. Once you have the parse tree or AST or whatever, then you perform that sort of analysis in the compiler
11:32:18
White_Flame
I guess that depends on if that concatenation is a lexical construct, a parser construct, or neither
11:33:10
White_Flame
obviously your language definition could demand that at any level, or leave it optional for the compiler to optimize. It would be fairly transparent to the actual source code, but not to implementers
12:29:48
ck_
it reminded me to see whether the source is available, or somebody ported it to today's CL
18:28:34
pfdietz_
For radix > 10, is there a way to get the printer to print the alphabetic digits in lower case?
18:34:34
ck_
does your lisp implementation offer anything, pfdietz_? Allegro CL has something called Case Mode, but I don't have one and can't check whether it applies to numbers
18:34:35
Bike
i don't think there's a flag you can use, if you're worried about doing this in the middle of some structure
18:36:37
sjl
if you're pretty printing you might be able to hack something together with http://clhs.lisp.se/Body/v_pr_ppr.htm
19:17:41
pjb
(format nil "~(~vr~) ~2:* ~:@(~VR~) ~2:* ~@(~VR~) ~2:* ~:(~VR~)" 16 255) #| --> "ff FF Ff Ff" |#
19:55:31
aeth
This ~( really simplifies doing this: `(progn ,(loop :for i :from 0 :to 100 :collect `(defconstant ,(intern (format nil "+~:@(~r~)+" i)) ,i)))
20:05:51
semz
Is there a standard way to get a nicely behaved nested REPL? (loop (print (eval (read)))) doesn't integrate well with SLIME and while I could of course mess with SLIME directly, it would be nice if it worked in a normal Lisp shell as well.
20:06:23
pjb
(list `(progn ,@(loop :for i :from 100 :to 105 :collect `(defconstant ,(intern (substitute #\- #\space (format nil "+~:@(~r~)+" i))) ,i)))) #| --> ((progn (defconstant +one-hundred+ 100) (defconstant +one-hundred-one+ 101) (defconstant +one-hundred-two+ 102) (defconstant +one-hundred-three+ 103) (defconstant +one-hundred-four+ 104) (defconstant +one-hundred-five+ 105))) |#
20:08:31
pjb
semz: you would have to modify com.informatimago.common-lisp.cesarum.utility:handling-errors to hook into the debugger.
20:10:20
pjb
Just calling (invoke-debugger) is enough. You might want to add some restarts to be able to come back to your repl.
20:29:12
minion
The URL https://gitlab.common-lisp.net/users/sign_in?secret=01667cd9 will be valid until 20:30 UTC.