libera/#commonlisp - IRC Chatlog
Search
0:14:37
opalvaults[m]
*no-defun-allowed* I love that guys writing. I believe he wrote a paper about a common lisp operating system that I really liked.
0:15:05
opalvaults[m]
hard to find through the website, thankfully i bookmarked it. For anyone interested: http://metamodular.com/closos.pdf
0:28:21
Spawns_Carpeting
I am not exactly sure what the type is in the first place, whether its a vector or hwat
0:29:00
Spawns_Carpeting
i could setup a local irc server for testing but it would be easier to uh, just know the type
0:29:30
Xach
Spawns_Carpeting: it's been a while, but i believe it's a vector of octets. octets-to-string will convert it if you like.
0:35:51
Spawns_Carpeting
how can I use sb-bsd-sockets inside of an asdf package? Do I need to :use something, or just require it?
0:43:21
Spawns_Carpeting
I am trying to logically work my way through this so I know how to do it in the future. I see that sb-bsd-sockets is itself an asdf "system", but I am not sure if the :use part of a defpackage imports systems, packages, or what exactly
0:45:35
Xach
Spawns_Carpeting: so, if you have a project with an .asd system file, :depends-on (#:sb-bsd-sockets) is a thing you could have in your file.
0:46:11
Xach
to refer to external symbols in the sb-bsd-sockets package without a prefix, you could :use #:sb-bsd-sockets in your defpackage form.
0:48:24
Xach
Spawns_Carpeting: it makes it so you can refer to their external symbols without a package prefix
0:48:47
Xach
so after (defpackage #:foo (:use #:cl)) (in-package #:foo), you can refer to CL:CAR without the "CL:" part
0:49:15
Xach
If you don't :use, you can still refer to them just fine - but you have to write the prefix.
0:49:59
Xach
there are a few ways to manage that sort of thing. importing is one, and shadowing comes into play when you :use multiple packages when there's a conflict
0:56:00
Xach
Spawns_Carpeting: it's a way to use a symbol for its name without interning it in any package
0:56:20
Xach
the real critical part is the name of the symbol - the #:... is syntax for a particular kind of symbol.
1:05:53
rotateq
dre: this dialect seems to be domain specific for programming robots too: https://staff.aist.go.jp/t.matsui/eus/
1:13:06
hayley
Per https://staff.aist.go.jp/t.matsui/eus/manual/node6.html#SECTION02013000000000000000 it seems unlikely.
1:28:50
rotateq
there's this interesting paper metacircular semantics for CL special ops surely you know it
2:04:00
Spawns_Carpeting
dash defines a bunch of handy functions for working with lists, like flatten, filter, map, take, take-last, take-while, etc etc etc
2:08:55
rotateq
Spawns_Carpeting: and it can also curry your meals :) or you do the alias "to schoenfinkel"
2:22:07
jstoddard
Hi everyone, say I have a class with three slots that have accessors a, b, and c. I want to create a subclass--all the methods on the original class make sense for my subclass, but it would make more sense to users if the accessors were named x, y, and z.
2:22:24
jstoddard
Is there a straightforward way to "alias" the names of those accessors for my subclass?
2:24:16
Xach
and when implementing a protocol it's not unusual to implement it with method names that don't match the slot name
2:27:35
jstoddard
I assume I can do the same thing with initargs -- (defclass subclass (class) ((a :initarg x :accessor x) ...))?
2:37:26
Spawns_Carpeting
how can i convert a string into a format suitable for using in socket-send?
2:39:04
rotateq
jstoddard: and for subclasses you of course can rewrite other options like initform or allocation
2:45:48
rotateq
just cause I see it now, it's a convention to place earmuffs around global parameters :) so one can say from reading "ahh that's a global parameter". and also wrapping constants with plus signs
2:46:54
hayley
And I wrote babel:string-to-octets after, with the babel: package prefix. Granted, IRC and programming is asynchronous. But you probably also want babel:octets-to-string instead of octets-to-string, to avoid the same error when you receive a message.
2:49:03
Spawns_Carpeting
i suppose it probably just loops through the string an creates a vector of char codes
2:52:11
rotateq
with it you load/build systems that define packages, which are container for symbols
2:56:05
jstoddard
Things work! You all just saved me potentially hours of tinkering around to figure out these little details about accessors, that I can now spend learning about what I'm trying to do (raytracing, if anyone cares). So thanks!
2:58:25
rotateq
improving the raytracer from Alexander Lehmann also with parallel and concurrent calculation or such could be a good go-on project and for rendering more complex scenes
3:04:08
jstoddard
Oh, he has videos up about raytracing in Common Lisp. Here I am working through a C++ tutorial rewriting things in Lisp.
3:08:21
jstoddard
Yeah, I never really got into C++, so it's kind of like speaking Spanish but trying to read Portuguese.
3:09:01
rotateq
One of the first big differences between C++ OO-system and CLOS is the decoupled classes and methods that are specializations to generic-functions with also possible method-combinations.
3:17:34
Spawns_Carpeting
how exactly do vectors work in lisp? I can't seem to get vector-push to work
3:18:42
hayley
(defvar *x* (make-array 10 :adjustable t :fill-pointer 0)) (vector-push-extend 1 *x*)
3:19:09
rotateq
or vector-push if it has a fill-pointer that is at the moment smaller than (1- length)
3:19:23
hayley
Er, the vector needs to have a fill-pointer, but it doesn't have to be adjustable for VECTOR-PUSH...
3:19:46
hayley
but I would recommend using an adjustable vector and VECTOR-PUSH-EXTEND, unless you know you definitely don't want resizing semantics.
3:20:56
hayley
A Common Lisp vector is just a one-dimensional array, whereas some languages use "vector" to mean a resizable one-dimensional array.
3:29:09
rotateq
ah okay. in CL they are also vectors specialized to element-type character and thous you can look up their length directly
3:32:55
Spawns_Carpeting
darn i am getting errors trying to decode the bytes from the socket into UTF8
3:39:38
hayley
I think something is going wrong if babel:octets-to-string doesn't work, but no one would know what, if you only say you are "getting errors".
4:00:35
Spawns_Carpeting
do I use setf of setq to set slots that have been brought "into scope" with with-slots?
4:06:32
Spawns_Carpeting
the problem was, I had the loop setup to read from socket until the message delimiter appears at least once in the connection buffer, but it was looping forever
4:06:53
Spawns_Carpeting
i fixed it though, i forgot to concatenate the buffer with the data from the socket
4:37:26
Spawns_Carpeting
what would something like (setf (struct-field struct) nil) do in terms of bytecode?
4:37:56
Spawns_Carpeting
a better question might be what exactly is going on when using the slot accessor functions
4:39:27
beach
There would likely be native instructions to compute the address of the slot and then store a new value at that address.
4:41:08
Spawns_Carpeting
I am thinking of a high level bytecode type of thing. just curious because I am still working on my personal lisp project, but haven't got as far as structs and classes yet
4:41:40
Spawns_Carpeting
im still in the early stages of compiling it actually, progress has been slow
4:42:37
Bike
if you're asking what the lisp compiler compiles into, it's not necessarily bytecode. sbcl and ccl both compile to native code for example.
4:43:20
Bike
if there was bytecode it would be the same way you do a structure access in pretty much any kind of instruction set, though? memory set kind of deal
4:43:35
Spawns_Carpeting
i mean, what kind of bytecode would it look like on a bytecode based lisp interpreter
4:44:39
Bike
doesn't have to be specialized. it's just an index into a structure and then a load from memory. or store to memory.
4:48:00
Spawns_Carpeting
i seem to catch on to the whole compiler thing a little more slowly than others
4:48:41
Spawns_Carpeting
i guess in my VM a struct slot accessor could just put a reference to a struct field on the stack or something
5:19:06
hayley
The easiest solution would be to pass the name of the slot to a SET-SLOT instruction, or something.
5:19:58
hayley
...and also some description of the structure that you want to write to, if you are checking types like an accessor function would.
5:45:34
Spawns_Carpeting
i have another question, sorry for asking so much stuff. are SBCL threads "managed", meaning I can use them without worrying about races and similar issues
5:46:28
Spawns_Carpeting
like, trying to read and write to something at the same time and ending up with the wrong value
5:46:57
hayley
As far as I know, Lisp implementations offer the same guarantees as Java, i.e. you'll read some written value and not total garbage.
5:47:50
dbotton
race conditions, they just map to system threads which do not provide any protections
5:48:21
hayley
(It's basically free on modern hardware, since cache coherency protocols just don't let you see word tearing.)
5:50:08
dbotton
Is there a way to "skip" adding to the return list during a mapping function like mapcar?
6:39:21
beach
dbotton: I recommend you do the thing that gives the most readable and maintainable code. Then you can measure whether your solution needs performance improvements and if so where.
6:40:00
beach
dbotton: Programmers are notorious for being wrong about what parts of the code take the most resources.
6:40:51
dbotton
Agreed. The remove nil version in this case more elegant and efficient enough for its purpose
6:41:42
beach
This is especially true for inexperienced programmers, who often fail to design good algorithms and data structures, and instead concentrate on what they (think they) know, i.e. low-level performance.
6:47:49
Bike
dbotton: you can do mapcan, returning a list of one element or nil. loop will probably be more readable though.