freenode/#lisp - IRC Chatlog
Search
0:24:47
pjb
jcowan: indeed. On Macintosh OS, most heap objects were referenced via Handlers which were indirect pointers. So the Memory Manager could move them updating only the pointer, and not the handle which could be copied in other objects or variables.
0:25:44
pjb
a lisp implementation could easily use handles to refer objects, instead of direct pointers, if that helped the memory manager/garbage collector.
0:26:30
White_Flame
and indirecting through symbols to find values/functions sort of does that already
0:33:45
andreyorst[m]
does anybody know any clever semi-nontrivial yet somewhat short examples of condition system usage? I'm porting CL's condition system to Lua, and wanted to make sure I got everything right. Example from the Practical common Lisp book works, and a bunch from the lisp wiki too, so if anyone can link some more examples it would be helpful. Thanks!
2:21:57
jeosol
Recently discovered C-c x for slime-export-symbol-at-point and it updates the (:export ...) section of the package with the symbol
2:54:01
jeosol
stylewarning: I did use it with postgresql but with comments that it's bit-rotted, I moved away. I didn't have much problems though for my simple use-case
2:56:24
jeosol
btw, I was hoping to have a conversion with you guys about productivity coding with Lisp. It's a beauty working with slime and all. As some of you know, I am working a large physics application for a few years. I once described it to someone during a work meeting, he said there is no way I wrote all that code in the time I said. By the way, he is
3:03:49
jeosol
I have already written the code - using CLOS mostly. Thanks to working though Sonja's book early one.
3:04:52
jeosol
In my case, I was rewriting more robust versions of graduate school codes. Started with matlab, then C++, then finally to lisp
3:08:15
mister_m
Is it possible to use a parameter list like (:a 1 :b 2) as keyword arguments to an invocation of make-instance?
3:38:24
mister_m
hm I am trying to create a property list to use with make-instance by reading input from a file, and using, for example, (list (make-symbol "input") "value") as a property list for the &rest portion of (apply #'make-instance 'my-class ...), but the resulting initarg is invalid. My class has a slot with an :initarg of :input, but the symbol I end up with as a result of make-symbol is #:|input| and doesn't seem to be compatible. How can I
3:42:07
beach
mister_m: You have two problems. First, using make-symbol creates an uninterned symbol, but what you need is a symbol in the keyword package.
3:42:36
beach
mister_m: Second, even though you would write :input, the name of the symbol is in upper-case.
3:42:56
beach
mister_m: So you first have to upcase the string and then intern it in the keyword package.
3:44:13
beach
When you write :input, that means a specific symbol in the keyword package, and trying a completely different one to pass to MAKE-INSTANCE just won't work.
3:44:35
pjb
and you would have the difficulty of using the same uninterned symbol: you'd have to keep a reference of it at compilation time (when the initarg is defined) and at run-time when it's used.
3:45:48
pjb
(let ((k (make-symbol "input"))) #|runtime class:|# (eval `(defclass koo () ((input :initarg ,k :accessor input)))) (let ((o (make-instance 'koo k 42) )) (input o))) #| --> 42 |#
8:56:41
h4ck3r9696
is it possible to implement common lisp like exception handling with scheme continuations?
8:58:00
beach
h4ck3r9696: Read phoe's book. All you need is a construct for non-local control transfer, and perhaps special variables.
8:58:52
beach
I am pretty sure first-class continuations could be used for non-local control transfer.
8:59:50
beach
h4ck3r9696: And I really like the terminology that phoe created, i.e., calling it "exceptions" only when they are dumb like in most languages, and "conditions" when they are like those in Common Lisp.
9:10:25
ChoHag
h4ck3r9696: Bear in mind that scheme's continuations are undelimited and drag along the whole computation.
9:11:14
Nilby
In scheme terms, you need catch, throw, and dynmaic-wind. You could use continuations if you assume infinite stack or every function is pure and tail recursive.
9:20:30
Nilby
"This SRFI cannot be fully implemented in R5RS because it requires special support from the system,"
9:21:45
h4ck3r9696
i can tweak the interpreter, so i don't think it will be problematic to implement
9:22:44
Nilby
but it also says: "defines an exception system whose essence can be implemented with CALL-WITH-CURRENT-CONTINUATION"
9:27:41
h4ck3r9696
beach: the less memory used by the language, the more can be used for other things
9:29:52
phoe
h4ck3r9696: the less time you spend writing your own code, the more can be used for other things too
9:30:48
beach
I think it's fine to write an implementation of something like Scheme in order to learn about compiler design.
9:32:36
beach
h4ck3r9696: It would be way more efficient to write a C or assembly routine for a major Common Lisp implementation, than to resort to C for the entire thing.
9:33:04
beach
h4ck3r9696: That is why I said that your "learning" reason is fine, but the others are way less convincing.
9:34:27
beach
h4ck3r9696: I say, don't let anyone tell you what you can and can not do. But also, don't fool yourself with bogus arguments.
9:35:22
beach
h4ck3r9696: I mean, it takes way less time to learn Common Lisp than to implement a scheme compiler for the purpose of scripting a C application.
9:36:00
beach
Fun and learning are good arguments. Not knowing Common Lisp right now is less convincing.
9:40:11
madrik
Should I #' lambda forms or not? Different sources tell me different things. Is it only esthetics?
9:42:03
pjb
I agree, normally you should not use #' with lambda. However depends on whether #' is the standard reader macro, of if you changed the read table.
9:42:15
madrik
The only argument I've heard for #' before lambda is that it expressly indicates the function-ness of the form.
9:42:59
pjb
(and then, even cl:lambda may depend on whether it's the standard read-table, or a read-table that has been changed to read in another package).
9:45:39
pjb
another example is ibcl: http://informatimago.com/develop/lisp/com/informatimago/small-cl-pgms/ibcl/index.html
9:46:23
pjb
IBCL could use the readtable trick so that cl:lambda for user code is not the Common Lisp LAMBDA… But instead it only tricked on in-package.
9:47:57
pjb
So if you write cl:defpackage you don't get ibcl:defpackage, but if you write defpackage, you get ibcl:defpackage.
9:48:31
pjb
It's important to keep in a corner of your mind the assumption with which you're working. Sometimes they're wrong.
9:49:56
pjb
For example people aways forget that entropy can only increase, but only in CLOSED systems. 1- we assume the whole universe is a closed system. 2- all the system with which we work ARE NOT closed systems!
9:51:33
pjb
madrik: the reason why I may refrain using them on internal functions is because check-type invokes the interactive debugger to resolve problems. You may want to avoid that on inner functions. But you would definitely want that for API functions and in general, functions closer to the user.
9:54:51
madrik
E.g., I learned about DEFTYPE, and thought it was possible to go overboard defining such types as positive-integer, nonnegative-real-number, etc.
9:55:29
pjb
For example (check-type i fixnum) (locally (declare (type fixnum i) (the fixnum (truncate i 2))))
9:56:35
pjb
The post assertion of check-type is that the place holds an object of that type, therefore you can tell the compiler that the object is of that type. (some compilers are dumb).
9:58:15
pjb
pyc: now, with format you can use ~& or ~%: (format nil "hello~%world") but this is not a string literal.
9:58:34
pyc
pjb: Oh, I want something like (let search-string "hello\n" ...) so that I can later do (search search-string my-string).
9:58:48
no-defun-allowed
I used funny-looking type specifiers for integers to let type inference avoid bounds checks on multiplication and all.
9:59:09
pjb
pyc: but actually we have the other, with ~newline: we can have newline in literal format control strings, and use ~newline to specify how this literal newline ust be interpreted:
10:00:39
pjb
Note that with ~newline, the prefix spaces on the following lines are ignored too. This let you indent nicely long string literals.
10:02:20
pjb
pyc: Using (format nil "hello~%") or #.(format nil "hello~%") wouldn't be too surprising. (let ((search-string (format nil "hello~%"))) (search search-string text)).
10:03:14
pjb
pyc: but you may also consider using cl-ppcre (cl-ppcre:scan (format nil "hello~%") (format nil "bonjour~% how do you hello~% world!")) #| --> 20 ; 26 ; #() ; #() |#
10:05:45
pjb
pyc: sorry, I meant: (cl-ppcre:scan "hello\\n" (format nil "bonjour~% how do you hello~% world!")) #| --> 20 ; 26 ; #() ; #() |#
10:06:23
pjb
pyc: cl-ppcre regexps are perl regexps, there "\\n" is interpreted as you want. (but it's not a newline character there, just a backslash and a n that is parsed by cl-ppcre.
10:06:50
pjb
pyc: finally, if you really need it (ie. you have a lot of strings with such escapes, you can of course define your own reader macro for #\"
10:14:35
pjb
So: (com.informatimago.common-lisp.c-string:enable-c-string-reader-macro) (write-string "hello\n\tworld!\n")
10:15:38
pjb
and: (com.informatimago.common-lisp.c-string:write-c-string "hello\n\tworld!\n") #| "hello\n\tworld!\n" --> nil |#
10:16:30
pjb
Well: (com.informatimago.common-lisp.c-string:write-c-string (format nil "hello~%~Cworld!~%~C" #\tab #\bel)) #| "hello\n\tworld!\n\a" --> nil |#
10:43:02
mfiano
Yes, don't use #'(lambda ...). There is at least one place where a lambda expression is mandated by the standard, not a function, and it's more verbose anyway.