freenode/#lisp - IRC Chatlog
Search
17:32:59
copec
The 'protocol for updating using semantics that follow from CL would suite it wonderfully, I think.
17:43:35
copec
That thought just came to me thinking about these micro controller system images being all lisp, something something nasa doing incremental upgrades through space via lisp, and how cloud app deployment is going towards orchestration (config management) states to deploy applications
21:01:31
dim
is there a guide to port CL software to ABCL? I mean the JVM comes with many libs that you can reuse without having to load CL equivalents I'm sure (jdbc for db drivers, zip, http, s3 maybe, usocket needs a replacement, json?, uuid?, base64?)
21:24:05
jackdaniel
I think that the proper way to tackle that would be defining a protocol (so the package and exported interfaces are defined) and to provide implementation for that
21:24:56
jackdaniel
example: uffi had a specification (which had implementation called uffi), and later cffi-uffi-compat iimplemented the same protocol and ecl ffi did the same
21:25:24
jackdaniel
so they are a drop-in replacements (you may use cffi-uffi-compat instead of original uffi)
21:30:42
dim
in the case of PostgreSQL/MySQL/SQLite/MSSQL/Oracle/DB2 and other database protocols, CL typically has a separate specialized driver each time where the Java world uses JDBC, often with quality drivers that you'd want to benefit from when you're on the JVM anyway
21:31:30
dim
so even though I like your idea of protocols and their various implementations, well... it's not clear how much that'd be necessary for me here
23:02:28
v0|d
pjb: #emacs guys had no ideas, do you know a way to make (mapcar (lambda (a) (concat "x" a)) (eshell/ls)) work?
23:04:23
pjb
of course, inside eshell it prints out the list. But as a function it doesn't return anything.
23:57:11
no-defun-allowed
could give the compiler more information for type inference and only works on simple vectors
23:58:50
malice_
didi: but SVREF does not work wherever AREF works. If you feed an array to SVREF you should get a type error.
23:59:12
malice_
Maybe I didn't mean type correctness but explicit type expectation or something like that
0:01:36
aeth
On the other hand, svref only works on simple-vectors, not (simple-array foo (*))s, and (simple-vector *)s have to be (simple-array T (*))s
0:02:41
aeth
Usually if you care enough to let the compiler know it's a simple array you also are probably using (unsigned-byte 8)s or single-floats or whatever.
0:03:13
aeth
Even if svref worked, that wouldn't give enough information: the type of elements held and the length are pretty important. So you basically have to declare when doing array stuff.
0:08:52
aeth
v0|d: A vector is a 1D array. A simple-vector is a 1D simple-array (simple means not adjustable, with no fill pointer, and probably a few more things that help compilers out) that holds elements of type T. This second part makes the concept of simple-vector alone a lot less useful than it could otherwise be.
0:09:44
malice_
What are you favorite Common Lisp libraries? I was thinking of cool common lisp libraries lately and was curious what are peoples' favorites.
0:10:27
aeth
v0|d: A simple-vector is incredibly niche. A simple-array can be common in certain use cases. So you basically always have to use aref (n-dimensional arrays) or elt (sequences, including vectors) and give enough type information to ungenericify the accessor.
0:11:41
aeth
v0|d: CL arrays are actually one of the stronger points for its types, especially when working with numbers (or characters)
0:14:25
White_Flame
in ye olde days, the calculation of the slot address within an array was much more expensive, and there were far fewer non-boxed values
0:14:36
aeth
malice_: You can have 0, 1, 2, ..., array-rank-limit dimensional arrays of character, simple-character, bit, and (not standard, but in almost every implementation) (unsigned-byte 8). You also normally can have fixnum, [un]signed-bye for 16/32/64, single-float, double-float, (complex single-float), and (complex double-float).
0:15:12
aeth
malice_: You can access all of this with aref, and you can define a type to greatly simplify the rather messy syntax (that would be a bit less messy if simple-vectors could be specialized for types like simple-arrays)
0:16:11
aeth
Seems like one of the stronger array offerings in a programming language, especially if you're working with numbers or characters.
0:17:07
aeth
malice_: Oh, and if an implementation doesn't support it, it will just become a generic T array instead of failing, so you can safely use (complex double-float) everywhere unless you rely on its checking for errors.
0:19:21
aeth
And in some implementations, :type in a struct slot will help out the type inference. So now these mostly-useless, legacy, pre-CLOS stuff (structs) have a purpose.
0:20:28
aeth
i.e. Have to pass around several arrays, but with a known length and numeric/character type? Put them in a struct with the appropriate array type as the struct slot :type and then non-generic AREF will be used and things will be much more efficient. Just declare/check-type/whatever the one struct's type, not the dozen arrays.
0:20:56
aeth
(And, in fact, it probably can tell it has to be that struct type, and thus the result has to be that array type, by the accessor's name.)
0:23:37
resttime
Been trying to get back into lisp again manipulating parsing/manipulating data from a csv
0:23:57
resttime
Got confused on floats being truncated until I figured out that it's because reads were doing it on 'single-float
0:24:05
aeth
malice_: oh one more thing, I should emphasize that most of this relies on optimizations permitted but not required by the standard, but that it will run (slowly) on implementations that don't implement all of those optimizations
0:35:25
jasom
resttime: there is also the parse-float library which is probably better for untrusted inputs
0:37:22
aeth
always write 1.0d0 or 1.0f0 (or 1.0l0 or 1.0s0) because you don't know what a prior system set that global to when asdf is loading your code
0:39:31
pjb
also, remember that floating point formats are different in different programming languages. So if you need to parse eg. JSON data, which uses the Java format, don't use CL:READ!
0:40:07
resttime
This was the value I was trying to parse "-87.381425", and oh I guess I dunno how to properly parse floats from a csv
0:42:30
jcowan
Why are simple vectors niche? I don't understand that. They are a very handy data structure with different tradeoffs from lists.
0:42:30
pjb
resttime: you can transform it into a ratio: "-87.381425" --> (/ 87381425 1000000) #| --> 3495257/40000 |#
0:42:34
jasom
resttime: that will parse it as a double float; if you want to parse it as an arbitrary precision decimal, perhaps someone else can recommend a library for that; I've not had cause to use decimal libraries in lisp
0:50:18
didi
aeth: In the past, declaring the type of a variable as FIXNUM has made wonders to my program, but I must confess, unless large integers are definitely ruled out from the domain of the variable, I feel uneasy.
1:05:38
malice_
though ratios are fine. They just aren't too fast, so while this approach is pretty straightforward and simple, it's also much slower. Just something to have in mind.
1:11:34
malice_
I mean, depends on your definition of broken. Definitely something to watch out for, but when dealing with floating numbers you should be aware of that.
1:14:54
didi
I once performed trigonometric operations in series, lots of them, with hilarious results. :-(
1:22:52
didi
Fun example: (loop repeat 1000 for x = pi then (* 2 x) finally (return (tan x))) => 1.6973400402517407, tho it /should/ has been ~0.
1:36:57
pjb
malice_ should have a look at https://github.com/informatimago/lisp-vs-c (as any other programmer looking for speed).
2:32:24
equwal
Is there a reason why Hoyte's defmacro! doesn't work in the repl while it does work when loaded from a file?
2:34:46
equwal
The production code https://github.com/thephoeron/let-over-lambda loads up, including other macros dependent on it. When I try to run it in SLIME I get 'g!whatever doesn't exist' kind of errors.
2:37:44
equwal
Do you understand that the point of defmacro/g! is to do automatic gensyms for |g!<name goes here>| variables?
2:38:47
equwal
So a trivial thing like (defmacro/g! test () `(list ,g!a ,g!b)) doesn't work in the REPL, as it expands to (DEFMACRO TEST () (COMMON-LISP:LET () `(LIST ,G!A ,G!B)))
2:41:12
Bike
Right. I mean I don't see why you'd get a bogus expansion in the REPL and a non bus one from compile-file.
2:45:02
equwal
(defmacro/g! test () `(list ,g!a)) --> 'undefined variable: G!A' in the compilation dialogue.
2:47:07
Bike
are you sure that the defmacro/g! here is the same as the one in this lol file? Like you didn't define your own defmacro/g! as a test?
2:54:17
equwal
Yeah I ran it from console with --no-userinit since I have an init script. I used all code from the book in my test file.
2:57:43
Bike
This seems like a good opportunity to mention that defmacro/g! is nonconforming code due to how flatten works, which is why the ersion on github there does special things for sbcl
2:58:04
Bike
You can see the one on github has ((typep x 'sb-impl::comma) (rec (sb-impl::comma-expr x) acc))
2:58:58
Bike
A few years (i think) ago SBCL changed its implemntation of the ` reader macro to expand into special structures instead of list structure
2:59:43
Bike
every few months somebody comes in here and asks why defmacro/g! doesn't work in sbcl, and this is why
3:00:41
equwal
It doesn't work even when you use the production code that does that thing you mentioned.
3:03:51
Bike
defmacro/g! is trying to do something outside the normal semantics, so it's kinda hairy.
3:22:22
pjb
Or you could not use backquote. list list* cons append are perfectly good to build sexps.
3:23:19
equwal
You mean in the (defmacro/g! ()...) forms? That would ruin the convenience of it a bit.
3:33:28
Bike
anyway, if you really want to do this my first suggestion is to not want to do this, but failing that i guess a reader macro would be the way to do it
3:34:46
Bike
because the g! stuff makes bindings etc implicit instead of explicit, making things a bit more confusing for readers
3:40:40
pjb
There's no secret: when you introduce functional abstractions, you get clearer, and more maintainable code.
4:22:32
aeth
didi: Integers are tricky because CL handles them properly so if you want to keep them in bounds in a simple and general way you probably want to manually implement C-style wrapping modulo arithmetic, like (mod (+ x 42) (expt 2 n)) and otherwise you need to do some fancy things
4:22:58
aeth
didi: single-float and double-float are really simple because CL handles stuff like nan and inf by erroring
4:48:44
White_Flame
equwal: when I wanted quasiquoted source code to be cons-traversable, I turned to fare-quasiquote