libera/#commonlisp - IRC Chatlog
Search
17:33:27
nick3000
Does anyone know if there is a simple way to create a 'bivalent' (I think I'm using that word right) in-memory stream with flexi streams or some other library? I was thinking some kind of class that just writes to one stream and reads from another. I want that because I am unit-testing some TCP-socket code that reads and writes to a socket. I was thinking if that was super hard I would just pass my server code two different streams,
17:48:19
nick3000
THe flexistream manual does use the word 'bivalent' but when I click the link to find a definition it does not point to anything with the word 'bivalent'.
17:51:20
nick3000
Okay so that is what I was looking for, if there was a library that allowed me to take an input and output stream and wrap them into a single bidirectional stream.
17:57:25
Nilby
but unfortunately I haven't published my text drawing program because it's not an emacs yet
17:59:42
Nilby
synonym stream is like an alias to another stream, e.g. so you can have a stream that is actually writes to whatever *standard-output* is set to
17:59:48
pjb
nick3000: for a bidirectional stream, you need two streams, (four ends) and connect their ends with make-two-way-stream.
19:03:57
CptKirk
I have a list of "0 1" and I want to repeatedly cycle over that list say, 10 times, collecting items from the list. say 0 1 0 1 0 1 0 1 0 1
19:04:55
CptKirk
I can of course write this in raw lisp, but I'm looking for a loop macro that does this if there is one
19:12:20
lisp123__
But append is highly inefficient, just wanted to show that its a useful keyword in the loop macro
19:15:08
yitzi
If you are not trying to do processing along the way (apply #'append (make-list 10 :initial-element '(0 1)))
19:16:42
rotateq
CptKirk: in general the #n= is for labeling a form and with #n# you can recall it so that the reader sets the form in at that place too
19:18:57
Alfr
CptKirk, for a non-circular list L which you are allowed to modify: (setf (cdr (last L)) L)
19:24:21
Nilby
It's just a copy and paste. The reader just copies #1 where it sees #1#. The cons cell is already created before it's contents are put in.
19:24:44
Alfr
CptKirk, it's not clear what you're asking. But as CALL-ARGUMENTS-LIMIT is an integer, it's finite, thus a circular list can't be a function call form.
19:26:46
CptKirk
@alfr I'm asking at what time does it expand the #1# reference because clearly it can't do that infinitely
19:30:48
Alfr
CptKirk, it doesn't. A proper list is either nil or a cons whose cdr is a proper list.
19:31:55
Alfr
CptKirk, you get a circular list if you modify a cdr of a cons in a list to refer to some preceding cons of that list.
19:34:04
Nilby
Here's without the reader trick:(let* ((l (list 0 1))) (setf (cdr (last l)) l) (loop for i in l repeat 10 collect i))
19:41:45
newlispurr
How do I put imports in a file in Common Lisp? (I'm using Portacle) If I put (ql:quickload :local-time) on top of my .lisp file, and run C-c C-k (compile and load) it doesn't work, but if run (ql:quickload :local-time) in the SLIME REPL and then C-c C-k again it works.
19:42:15
newlispurr
What should I put in my .lisp file so I don't have to run (ql:quickload :local-time) in the REPL every time I restart Emacs?
21:01:03
Alfr
pjb, sure when I make one. Some of my stuff are just single files in PATH, that's what I assumed he wanted such behavior.
21:01:28
pjb
CptKirk: you cannot have circular structures in the source code, but you can have them in literal objects (quoted or self-evaluating).
21:02:02
pjb
Alfr: so you explained how to use eval-when to put quicklisp in source file. Which is what he shouldn't be doing.
21:03:23
pjb
CptKirk: the source code is processed by the compiler. if you use structuring sharing, including circular structures, then the compiler may not terminate, or have other bugs because of the sharing. But this doesn't matter for data, which is data, and is not processed by the compiler.
21:04:02
pjb
CptKirk: the only processing of literal data the compiler performs, is possibly identifying common substructures in literals, and share them in the object file.
21:04:57
Alfr
pjb, I never said it's best practice. And I usually use it with load-system only -- not ql.
21:05:02
pjb
CptKirk: note: I use the term structure in a general way here, because #=/## can be used across cons cells, vectors, structure objects, and other read forms.
21:06:01
pjb
Alfr: the penalty is that you might eventually have to maintain the bad code he writes…
23:00:13
hendursaga
How should I go about typing a function that returns the output of an already-typed function? Just "function" and the rest is inferred or what?