freenode/lisp - IRC Chatlog
Search
13:21:58
pjb
pyc: note that it is dependent on the implementation too. You may want to benchmark and see what works better for your (application cl-implementation) pair.
13:23:39
pjb
pyc: notably, asymptotic behavior doesn't say anything about the constants, and that's just expectation we have on implementations. Sometimes we may have surprises… (for example, on an unrelated note, reader macros are put in a sequential list in ccl, so when you have a lot of them (say on each unicode character) it becomes very slow to read stuff).
13:24:33
pjb
pyc: have a look at: https://github.com/informatimago/lisp/blob/master/common-lisp/cesarum/string.lisp#L159
13:36:44
pjb
(dolist (x '(1 2 3 4 5 6)) (block continue (if (oddp x) (return-from continue)) (prin1 x))) #| 246 --> nil |#
13:36:53
Colleen
Bike: drmeister said 1 hour, 9 minutes ago: I'm getting a cascade of errors when generating backtrace...
13:36:53
Colleen
Bike: drmeister said 59 minutes, 50 seconds ago: Are you making an assumption about what the output from backtrace_symbols looks like?
13:37:15
heisig
pyc: The body of dolist is like a tagbody, so you can simply introduce labels and go to them.
13:37:45
pjb
(dolist (x '(1 2 3 4 5 6)) (if (oddp x) (go continue)) (prin1 x) continue) #| 246 --> nil |#
14:46:34
engblom
I made a tool for tidying lisp files based upon (pprint (read)). I run it on itself and here is the result: https://pastebin.com/16QCHEw0
14:48:58
phoe
also, (loop ... do (pprint form) (terpri)) - unnecessary progn, and an explicit newline operator
14:49:16
theseb
In SICP, authors implement eval and make a point of saying to actually INVOKE functions, you need a special form called "apply". However, in Paul Graham's "Roots of Lisp" which I've always liked he does NOT make a point of saying you need a special extra operator like apply to implement eval...why?
14:49:19
phoe
also (read in nil) is going to be buggy if the file contains a literal () (which is possible)
14:50:51
heisig
engblom: You should use some library for handling command line options, at least once your programs grow larger. Something like https://github.com/didierverna/clon
14:51:20
phoe
theseb: likely because the syntax of RoL's lisp allows for ((lambda ...) ...) style which is an implicit APPLY
14:52:02
heisig
engblom: Apart from that and the use of SETQ, that's a neat little program. Welcome to Lisp, try not to get too addicted :)
14:54:49
Bike
i think mostly roots of lisp is a sloppy (or, more charitably, simplified) article that shouldn't be relied on for details
14:54:52
phoe
and, if a list '((lambda ...) ...) is your function call, then evaling it is the implicit APPLY I meant
14:56:14
theseb
Bike: i suspect RoL made a lot if Lisp fans...I've personally been more fascinated with the RoL than I'd care to admit
14:56:15
pjb
Bike: "article" you're generous. Nothing like that. It's a mere "memo", two dactylographed pages to let know fellow searchers of the AI Lab what John was up to. Namely, AIM-8: http://informatimago.com/develop/lisp/com/informatimago/small-cl-pgms/aim-8/index.html
14:56:46
jcowan
You can write aa simple APPLY-EVAL pair that constitute a classical Lisp interpreter. Needless to say, few Lisps around today actually provide this.
14:56:47
phoe
eval. accepts the form to be evaluated and the environment - do we have access to it inside RoL itself?
14:57:59
phoe
and since it's just Lisp data, I guess we can make a special form that returns the current environment that can then be passed to eval. again
14:58:38
engblom
I did not go for the libary for parsing arguments at this point, as this tool will probably never grow. I fixed the rest: https://pastebin.com/TuZrmfn2
15:01:28
phoe
also SYNTAX-ERROR is a slight misnomer because it does not really signal a CL error; maybe name it PRINT-HELP-DIALOG instead?
15:01:46
phoe
theseb: actually when you have stuff like ((1 . 2) . 3) I'd be scared to use first/rest on it
15:02:49
pjb
theseb: APPLY is not a special operator, it's a primitive function. FUNCALL can be implemented calling APPLY but the reverse cannot be.
15:03:47
pjb
engblom: and yes, since they are global variables, you don't want to mess with the code in the other threads, or to mutate them for the rest of the REPL session. So use LET.
15:03:58
theseb
pjb: wow....i was assuming primitive function == special form == special operator....didn't know people here distinguished between those terms
15:06:44
phoe
but, yeah, the fact that some CL operators are functions does not mean that they can be expressed in terms of anything else
15:06:49
pjb
theseb: (if (= a b) 'yep 'nope) is a special form. IF is the special operator. APPLY is a "primitive" function in that it cannot be implemented in lisp without using metalinguistic abstraction. In the case of Common Lisp, all the functions in CL can be open-coded, which means they could be considered like special operators in a way. But special operators are a more specific set of 37 operators in CL. Note that macros in CL ca
15:06:49
pjb
implemented as special operators technically, but the implementation still has to provide an equivalent macro for users of MACROEXPAND.
15:08:06
Bike
"special operator" means an operator with special evaluation semantics. apply has the same evaluation semantics as any other function: in (apply a b), a and b are forms to be evaluated. so it's not special.
15:08:06
pjb
in any case, that doesn't mean that you cannot implement everything in CL. It's just that there's one level of metalinguistic abstraction required (ie. a compiler or an interpreter).
15:20:46
_death
(let ((c 0)) (do-external-symbols (sym "CL") (when (special-operator-p sym) (incf c))) c) => 25
15:21:01
pjb
(let ((n 0)) (do-symbols (s "CL" n) (when (special-operator-p s) (incf n)))) #| --> 25 |#
16:56:40
Josh_2
I'm sat here thinking I wonder if there is a destructuring-plist, turns out you can just destructure a plist using &key ...
17:01:40
Bike
http://ix.io/3cvy here is how i would do a roots of lisp thing. makes the difference between a special operator and built in function clearer. would be more involved to make it self hosting, though
17:46:22
pjb
pyc: note how concatenate-string is faster when you have more than between 50000 and 100000 strings to concatenate. (may also depend on the length of the strings).
17:47:29
pjb
pyc: but when you have about 1000 strings, apply-concat is faster (in ccl, and given that call-arguments-limit #| --> 65536 |# );
17:51:46
copec
speaking of destructuring plists, a snip from the project I'm working on Josh_2 https://unaen.org/pb/1ym
17:55:32
Josh_2
well from what I just learned you can use (destructuring-bind (&key <your keys> &allow-other-keys) <your plist> <body>) to destructure a plist
19:09:51
pjb
About SBCL 2.1.3, I wonder why I get "Control stack exhausted during signal emulation: PC: 52077ee2" crashes, when call-arguments-limit is 4611686018427387903 ?
20:02:59
copec
anything more then one line I dump in a file in another buffer and ctrl-c-c each form anyways
20:06:33
copec
Even though for most of my programming I use sbcl, I wish clisp would have been the python
20:47:50
copec
#osdev is pretty popular, there should be a #lispdev, where people hang out who have reached the phase of trying to bootstrap their own lisp
21:34:42
dieggsy
FWIW this seems to work ok https://stackoverflow.com/questions/25809493/how-can-i-get-syntax-highlighting-for-common-lisp-in-slimes-repl#26050762
21:34:56
dieggsy
i changed it to lisp-font-lock-keywords instead of keywords-2... not really sure...
21:37:07
opcode
if i specify a literal as #o00 is that the null byte \00? coming from the C-family and finding lisp's type system very unintuitive
21:38:28
moon-child
opcode: in cl, characters and numbers have different types. So #o00 is another way to get the number 0
21:38:51
moon-child
if you want to make a character from a number, use code-char. e.g. (code-char 0) ←→ #\nul
21:39:21
opcode
i'm fiddling around with ironclad, and I want to make an initialization vector for AES that's just 0x00's. Is #\nul what I want?
21:41:16
opcode
but it's not clear to me from reading the hyperspec what exactly is equivalent to what
21:43:22
opcode
k. i find the docs very dense, but perhaps that's just because I have no formal CS training :/
21:45:14
Xach
opcode: i think ironclad is probably most useful if you already know generally how the algorithms are set up and used and you just need a reference for use
21:50:23
moon-child
standards documents are frequently like that. You have to learn to read standardese ;)
22:06:56
pjb
opcode: (make-array 4 :initial-contents '(#\null 0 nil "nope")) #| --> #(#\Null 0 nil "nope") |# ;-)
22:15:14
Xach
i find the hyperspec to be a fantastic reference, but it helps that i've spent a long time getting used to how it presents info.
22:36:47
copec
It is fantastic after you get it :-P If I don't understanding something, it's like it falls on deaf ears until I already understand it
23:34:27
White_Flame
I made a (defmacro fast-body (&body body) ...) which just wraps the body in a locally declare optimize
23:36:49
White_Flame
If you have multiple versions for different architectures, there will probably be #+ based compilation or file inclusion somewhere to select between them
23:37:27
White_Flame
so only 1 version is probably in existence? the other thing affecting it would be optimization declarations