freenode/#lisp - IRC Chatlog
Search
9:41:54
beach
Just so you know that you need to know the details of the GC in order to know how to optimize for it.
9:42:44
dim
the main thing I do is receive bytes from the network (typically a database driver gets that for me), then I push the data (vector of strings) into a lparallel queue (pointers, no copy), then another thread pops from the queue and transform the data into another vector of (unsigned-byte 8) this time (utf-8 representation ready for pg copy protocol), and then we send that up the network again to pg
9:43:35
dim
I also have a “batch” notion that happens after the transform and before pushing in the network to pg, where I keep around everything that is going to be sent in vectors of 25000 elements, so that in case of error I can replay the vector and skip erroneous lines
9:43:50
beach
dim: Maybe the SBCL maintainers can draw some conclusion from that use case. I certainly can't.
9:59:13
xificurC
we're trying out ABCL in a java app, planning to use it as a scripting language. My problem is with multithreading. If 2 threads are creating a new package will they clobber each other or can I ensure thread safety for them
12:43:21
xificurC
anyone knows an equivalent of `dirname $0`? I.e. finding the directory of the lisp file that is being loaded
14:15:44
klm2is
When I define a method in allegro cl with (defmethod foo ((x string)) (declare (ignore x)) (values)), I get a compiler warning for the variable x being used although it was declared ignored. Is this true of other implementations? Should it work this way?
14:17:08
Bike
"The expansion of the defmethod macro ``refers to'' each specialized parameter (see the description of ignore within the description of declare)." says clhs defmethod
14:17:10
klm2is
Makes sense. I was trying out cl-mustache and noticed that it has code like this in some places. I didn't know if that was an implementation thing.
14:19:14
klm2is
@Bike I read that, but I didn't know whether it's then required for the implementation to provide a warning.
14:21:06
Bike
it's not required to, but it's certainly allowed to, which is what you're concerned with, no?
18:13:25
pjb`
creating git repository should always be the first thing to do in a project (well just after ordering the t-shirts).
20:00:01
araly
hey everyone, I have a question, if I have a function like (parse-integer) which returns two values, the number parsed and the size of the string understood, how can I use both ?
20:29:24
aeth
That's not actually an exhaustive list. There's also (setf (values ...) ...) which is probably built on multiple-value-setq
20:37:44
aeth
If I used nth-value I'd probably wrap it in a trivial function just to make it more readable.
20:38:16
aeth
I bind all of the values and then discard the one(s) I don't use. Ideally, the compiler will optimize it to be the same as nth-value
20:39:00
araly
so where would I put my function that returns two values, at the place of "whatever" ?
20:40:22
aeth
It depends on what you're going for, though. If it's common enough just defining a trivial function is probably the way to go. e.g. (defun hash-table-value-exists-p (key hash-table) (nth-value 1 (gethash key hash-table)))
20:41:56
aeth
But imo you should either do a function wrapping nth-value or a multiple-value-bind that ignores the values you don't need because either will be more self-documenting than just using nth-value.
20:44:25
araly
well for this time I'm just using the second value of a function once, but I will turn it into a function if it turns out I use it again after
20:45:51
aeth
For very trivial functions that are small and probably will never change, you can declare them inline above the function definition, e.g.: (declaim (inline hash-table-value-exists-p))\n(defun hash-table-value-exists-p (key hash-table)\n...
20:46:11
aeth
So there's basically no reason not to use trivial functions when it makes the code better. It's very idiomatic.
21:04:21
stylewarning
Has anybody worked on or thought about being able to write small snippets of inline C code in Lisp?
21:11:13
MichaelRaskin
Cmera (or how is it even written) would even allow you to generate C from Lispy syntax
21:19:14
aeth
I generate a limited subset of GLSL from s-expressions. Nothing really stops me from finishing GLSL and then also adding what syntax C has on top of that.
21:20:53
aeth
The strings can even be made at compile time from the expressions. It would greatly complicate your build process, though.
21:23:36
aeth
It wouldn't be truly "inline" because the C compiler wouldn't be cooperating, unless you built the C compiler yourself, which is totally doable non-portably in SBCL.
21:24:22
stylewarning
I mean, sometimes it's annoying to write Lisp code that looks identical to C, except it's 10x more verbose and still less performant.
21:24:45
stylewarning
Maybe it would be nice to just compile a C function to some anonymous library and dynamically load it or something, I don't know.
21:25:09
aeth
Are the internals exposed by SBCL (e.g. define-vop) sufficient to write a C compiler with?
21:26:31
aeth
That would be an interesting alternative to relying on foreign C, although it wouldn't be portable.
21:28:25
aeth
I don't really have issues with verbose low-level CL, though. The thing that's the most verbose compared to C-style-syntax is probably aref, but I even have a with-accessors equivalent for that now in with-2D-array-accessors. https://gitlab.com/zombie-raptor/zombie-raptor/blob/184e235be3974ebc3b062b3fb94559c2e15797f9/util/array.lisp#L106-144
21:28:59
aeth
The result is something that's more verbose than using aref directly, but probably still more readable.
21:29:30
aeth
e.g. https://gitlab.com/zombie-raptor/zombie-raptor/blob/184e235be3974ebc3b062b3fb94559c2e15797f9/render/gl.lisp#L180-197
21:30:47
stylewarning
aeth: maybe because you don't read enough bitwise arithmetic and prefer things spelled out because a DSL doesn't make sense for you
21:31:47
aeth
stylewarning: well e.g. I prefer something like this for a common use case of bit operations: https://gitlab.com/zombie-raptor/zombie-raptor/blob/184e235be3974ebc3b062b3fb94559c2e15797f9/math/boolean-set.lisp