libera/#commonlisp - IRC Chatlog
Search
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.