freenode/#lisp - IRC Chatlog
Search
2:43:36
aeth
PuercoPop: This works because if it's (expt 2 31) or higher its quotient will be 1 instead of 0, which means it will become negative.
2:44:00
Bike
isn't it the opposite direction? you have thirty two bits off the wire and now want a signed integer?
2:44:55
aeth
Bike: This goes unsigned->signed. So you're combining the four bytes as if it was an (unsigned-byte 32) and then you're turning it into the equivalent signed representation for the same bits.
2:46:59
aeth
If it's 0 to (1- (expt 2 31)) this does nothing, if it's (expt 2 31) to (1- (expt 2 32)) it converts it properly, and it's not valid past that because it's only for ub32s
2:49:30
aeth
i.e. (defun ub32-to-sb32 (number) (declare (type (unsigned-byte 32) number)) (multiple-value-bind (quotient remainder) (floor number (expt 2 31)) (- remainder (* quotient (expt 2 31)))))
2:55:43
aeth
My function is correct because I just compared its behavior to this function in a loop and every ub32 had an = result. (defun cffi-abuse (number) (declare (type (unsigned-byte 32) number)) (cffi:with-foreign-object (i :unsigned-int) (cffi-sys:%mem-set number i :unsigned-int) (cffi-sys:%mem-ref i :int)))
3:06:12
PuercoPop
Bike: iiuc you and aeth are talking about the same direction. But yeah this is the code in question https://github.com/zzkt/osc/blob/master/osc.lisp#L332
3:06:54
PuercoPop
And nyef's code (defun u32->s32 (value) (if (logbitp 31 value) (logior #x-80000000 value) value))
9:21:54
dim
I've heard about the BBC initiative for exposing kids to programming, the Micro-Bit, a kind of very cheap arduino board with many popular extensions; and to program it in Lisp all I can find at the moment is http://www.ulisp.com/show?2672
9:22:20
dim
do you guys know if there's an implementation of Common Lisp that would target this little board?
9:29:26
no-defun-allowed
also, it has one of those separated code and data models that make COMPILE pretty useless
10:07:46
vaartis
wanted to ask if there's a way to bundle static files when building the program with something like program-op?
10:08:54
vaartis
and is it a decent idea to bundle a dynamic library with an asdf system that someone might install from quicklisp, and if so, how do i do it
10:18:55
vaartis
I see.. I want to write bindings for a certain library that isn't in linux package managers, but takes less than a minute to build and doesn't have any dependencies, so i though about maybe just building it for most platforms and bundling like this python thing does http://www.pymunk.org/en/latest/index.html
10:19:28
loke`
vaartis: You can ship the source code as part of the package and then build it if needed.
10:20:06
loke`
THat's something I believe IOLIB should do with libfixposix, but the author don't agree
10:22:15
loke`
vaartis: Windows is an oddball. Personally I don't really pay much attention to that one.
10:23:25
vaartis
The problem is, asdf doesn't copy static fles to the destination directory when using e.g. program op
10:36:50
vaartis
https://common-lisp.net/project/asdf/asdf/Predefined-operations-of-ASDF.html#Predefined-operations-of-ASDF
13:07:30
jcowan
Question: when if ever does it make practical sense to mix &optional, &rest, and &key in a single lambda list, other than the special case of &allow-other-keys?
13:09:48
Bike
&rest and &key together is useful if you want to throw your arguments at some other function
13:14:05
jcowan
Right. I didn't think of the pass-along case, only of the crack-keys-yourself case (like structure constructors)
13:16:05
jcowan
I'm glad to hear that &optional and &key together doesn't make sense. I am evaluating a pair of macros for Scheme, which has only &rest (spelled "."), one for optional arguments and the other for keyword arguments. I was checking that it made sense to separate them.\
13:16:37
Bike
i mean the rules are consistent and everything, and the code will compile and run... it's just confusing
13:17:17
jcowan
I feel no great need to push for the standardization of functionality that serves only to confuse people. :-)
13:19:13
jcowan
in my context that would mean using the macro (which accepts a rest-list and binds variables corresponding to the keywords) as well as the raw rest-list itself.
13:19:54
pfdietz
I wonder if SBCL tries to check if a &rest arg's list is being mutated (the list itself, not the objects in the list)
13:22:00
pfdietz
It's permitted (but not required) for a CL implementation to reuse the last argument to APPLY as part of the rest list, so destructive modification of that list is a no-no.
14:05:02
pfdietz
Better to have some sort of "rest args object" from which a list could be obtained, if needed. APPLY would take one of these (or a list) as a final argument.
14:14:17
pfdietz
WHich means that list is being copied. Gets expensive with very long lists. This shows up in a programming style where one adds new :key arguments to this list down a call chain.
14:17:03
jcowan
Standard Scheme has no keys at all. The macro I'm looking at will not reject multiple uses but ignores all but the first.
14:18:30
jcowan
The signature of the macro is (let-keywords ls ((var [keyword] default) ... [rest]) body ...) where ... is postfix for iteration. Note that the variable can have a different name from the keyword, though you probably won't want that much.
14:25:36
jcowan
As I was saying, you put a newly consed object into a non-exported global variable and set that as the default: no one can pass you that object, so an eql test shows whether the keyword is missing or not.
14:28:04
jcowan
I have used the same trick for alists as poor man's objects: if the first element in the alist is (<unique> . foo), code that cares can treat it as of type foo, and to code that doesn't it's just an alist.
14:30:58
flip214
If I hang around here for some more time, I might be one of the elders... probably still not considered wise, though.
14:37:20
pfdietz
Talking about scheme to shed light on CL issues is borderline acceptable for #lisp :)