libera/#commonlisp - IRC Chatlog
Search
19:03:08
phoe
Guest74: remember to grab the updated code from imago and not from my commit, there were some fixes made later on
19:37:00
Josh_2
I used to use http://wiki.c2.com/?ImageBasedLanguage but the site appears to be dead :cry:
20:02:50
nij-
Hi! I'm using sly in emacs. However, its completion doesn't work. When I do M-x sly-next-completion, a message says "No buffer named *sly-completion*." Anyone had this issue before?
23:43:43
jmes
When I use the executable of my program (built with asdf:make & sbcl), my (format t "...") output only gets displayed in a terminal after I exit the program. In SLIME it's fine. I'm pretty clueless so any ideas would be appreciated.
23:45:54
jmes
for example I have a prompt like (format t "Enter something:") and then a read-line. Even though I can enter something to be read and everything else works as intended I won't see the prompt text until I SIGINT the program
3:40:45
pillton
Bike: I was referring to operations involving AREF like (dotimes (i (length array)) (incf (aref array i))) where there is nothing you can do to hint that the index given to AREF and (SETF AREF) is always valid for ARRAY (well, something more sensible than (declare (optimize (speed 3) (safety 0)))). A "sufficiently smart" compiler could possibly derive that example, but what about more operations for more complex data structures e.g. a
3:40:45
Colleen
pillton: Bike said 13 hours, 36 minutes ago: "I think there should be another operator or operators introduced which either avoid using AREF or ensure that every call to AREF does not require checking its arguments." what do you mean?
3:40:45
pillton
heap? One could argue that the cost of the index check is negligble compared to some of the heap operations and thus not worth exploring.
3:41:39
pillton
Bike: Perhaps a better example is (dotimes (i (length array2)) (incf (aref array1 (aref array2 i)))).
3:43:49
pillton
Bike: I get the concurrency argument, but I think there is something more fundamental that needs to be addressed.
3:45:51
pillton
Maybe the problem goes away if you define operations which operate on "blocks" with a fixed length i.e. simd operations?
3:47:03
pillton
But there has to be a safer way to implement optimize operations like matrix multiplication, SVD, proximity operators, heaps without resorting to (declare (optimize (speed 3) (safety 0))).
3:47:58
yottabyte
how do you all feel about this? https://github.com/cl-boost/threading. I found such macros useful in clojure
4:13:39
Bike
pillton: short version would be like, the ability to declare that an array's length is some other variable.
4:18:03
Spawns
lisp macros can call any functions eval'd before the macro definition yeah? how does that work?
4:18:52
Spawns
i am at the point where the next thing i need to implement in my lisp is macros, but I'm not sure how to deal with generating bytecode and expanding macros that depend on programs, which are bytecode
4:19:43
Spawns
i am thinking to compile and interpreter a single expression at a time, and the compiler is going to have to be able to pass in data to be expanded while compiling
4:20:29
Bike
Spawns: generally, the lisp compiler has access to a lisp interpreter or other way to evaluate lisp code. it then just calls the macro function on the code.
4:20:41
Bike
pillton: it is. makes your type system uncomputable and stuff. but lisp's already is, so hey
4:21:24
Bike
"this array is x long, so if (0 <= y < x), (aref array y) doesn't have to bounds check"
4:21:32
moon-child
Bike: why would you need an interpreter? Aside maybe from bootstrapping, I see no reason why you could not compile the macro body
4:23:14
Bike
i didn't mean to say you couldn't use it. i am trying to explain this to someone who is perhaps not familiar with the internals of lisp implementations.
4:26:29
beach
Spawns: It shouldn't matter whether your Lisp functions are implemented as bytecodes, primitive functions in assembly, interpreted functions, native code, or anything else. A macro is expanded by a call to the macro function which is given an S-expression (and an environment in Common Lisp), and which returns another S-expression.
4:50:30
beach
Spawns: It is very hard to help you with this thing, because you are implementing a language for which we have no specification. So we have no way of knowing what kind of restrictions or generalizations your language has compared to Common Lisp. The best thing we can do is to let you know how things would be done in a typical Common Lisp implementation.
4:52:55
beach
Spawns: So with that in mind, in Common Lisp, a macro function is just an ordinary function that takes two arguments, a form and an environment object. The function builds a new form and returns it. It doesn't matter, then, whether the macro function is coded in assembly or something else.
4:55:23
beach
Spawns: You can check this for yourself in a Common Lisp implementation: (funcall (macro-function 'when) '(when foo bar baz) nil)
4:55:37
Josh_2
Okay I have found that annoying bug again, ofcourse it occurred when I deployed my application to my VPS
4:57:27
Josh_2
Okay https://plaster.tymoon.eu/view/2871#2871 here I have at the top my macro, then in the middle the function using the macro and then at the bottom a condition that is signalled when evaluating a function (in a different package) that is using the function in the middle
4:58:29
Josh_2
Not sure why I am getting this error, the reason I had to use keys is an attempt to make conversion from destructuring-bind to with-hash-keys easier
5:15:23
asarch
If I have: '((:id 1 :name "taco") (:id 2 :name "pizza") (:id 3 :name "beer")), how could I remove (:id 2 :name "pizza")?
5:23:21
moon-child
could use EQ if you guarantee structure-sharing ahead-of-time. Or use a hash table if you have a bunch of elements to remove
5:23:55
asarch
Then I could have '((:id 1 :name "taco") (:id 2 :name "pizza") (:id 3 :name "beer")) and then a list of ids '(1 2)
5:24:23
asarch
(loop for element in '((:id 1 :name "taco") (:id 2 :name "pizza") (:id 3 :name "beer")) do (remove-if ... <- ?
5:27:09
moon-child
remove-if says exactly what it does: you're removing some elements from a list. It is more specific
5:32:52
asarch
But how can I pass the list of the elements I want to delete?: (remove-if (lambda (x) (member x '((:id 1 :name "taco") (:id 2 :name "pizza") (:id 3 :name "beer")))))
5:36:45
moon-child
(let ((ids-to-delete ...)) (remove-if (lambda (x) (member (getf x :id) ids-to-delete)) list))
5:37:31
moon-child
ids-to-delete is available to the function you create, so we say that the function closes over ids-to-delete
5:38:39
akoana
just for fun, what about (set-difference '((:id 1 :name "taco") (:id 2 :name "pizza") (:id 3 :name "beer")) '((x 1) (x 2)) :key #'second :test #'equal)
5:39:46
asarch
(remove-if (lambda (x) (member (getf x :id) '(1 3))) '((:id 1 :name "taco") (:id 2 :name "pizza") (:id 3 :name "beer")))
5:42:14
moon-child
ACTION considers pointing out that j's 'hook' combinator obviates the misdirection, decides against it
5:42:39
asarch
(set-difference '((:id 1 :name "taco") (:id 2 :name "pizza") (:id 3 :name "beer")) '((:id 1 :name "taco")) :key #'second)
5:52:28
Spawns
is it possible to have my interpreter's implementation of conses as an immutable data structure but provide a mutable api to the lisp itself? do any cl implementations do something like that?
5:53:22
Spawns
i am sort of confused how you could implement that, since lists don't store pointers going backwards
5:54:39
Spawns
appending and pushing is easy, but doing set-car or whatever to an element in the middle is tricky
5:57:13
beach
Spawns: I have no idea what that means. Mutability doesn't seem to have anything to do with back pointers.
5:58:04
Spawns
how can you create a new list when doing "set-car" in the middle of a list, if you can't copy the list from front to back with just that part of it changed
5:58:13
beach
And I don't see the difficulty of doing a RPLACA "in the middle" whatever that might mean.
5:59:18
Spawns
like with appending, you just make a brand new list with an extra element tacked on the end, pushing you do the same but with the front. setting a car however, just gives you a single cons cell from the list, so you don't know how to return an entirely new list with just that part changed
6:01:44
moon-child
Spawns: obviously, immutable languages are turing-complete, so you _can_ implement a mutable language in terms of immutable semantics
6:02:58
moon-child
Spawns: setf is a macro. In the case of CDDR, that will expand to something like (rplacd (cdr list) nil)
6:03:01
beach
I would appreciate not being corrected when I attempt a pedagogical approximation to a newbie.
6:03:23
Spawns
i think you are right about performance moon-child, that will be a lot of allocations and general churn
6:04:16
Spawns
the main reason I am asking is because doing mutable link lists in rust is a massive annoyance
6:04:21
beach
Spawns: More generally, this is a channel for Common Lisp. You are attempting the implementation of a different language for which we have no specification, so it is nearly impossible to give you advice.
6:04:46
beach
Spawns: I think you need to phrase your questions in terms of how Common Lisp is or can be implemented.
6:04:53
moon-child
Spawns: I think I told you before that trying to implement lisp in rust was not going to work out
6:05:14
Spawns
i was curious if you are familiar with how cl implementations implement their lists beach
6:05:45
minion
Spawns: SICL: SICL is a (perhaps futile) attempt to re-implement Common Lisp from scratch, hopefully using improved programming and bootstrapping techniques. See https://github.com/robert-strandh/SICL
6:06:40
beach
Spawns: Usually, a CONS cell consists of two consecutive words in memory, and a list is just a sequence of CONS cells, linked by their CDR.
6:07:16
beach
Spawns: SICL bootstrapping? The compiler is written in Common Lisp and generates native code. Or will, when we are done.
6:08:33
beach
Spawns: You might want to read the paper by Krystof, entitled "SBCL, a Sanely Bootstrappable Common Lisp". SBCL is mostly written in Common Lisp as well.
6:09:55
beach
Spawns: You might also watch my videos for the online Lisp meeting, entitled "Creating a Common Lisp implementation".