freenode/#lisp - IRC Chatlog
Search
19:49:47
Xach
http://report.quicklisp.org/2020-09-25/failure-report.html shows some optima-related breakage
19:51:35
Xach
(I am pleased with my new report format, which pulls critical ERROR/WARNING info out into the main index page)
19:52:55
scymtym
yeah, fare-quasiquote seems to have been "fixed": https://gitlab.common-lisp.net/frideau/fare-quasiquote/-/commit/28c556771c5551339bbd86306cc01f76caa0700f
19:53:12
rustisafungus
so, i am language-surfing, for fun. i get the impression that the lisp community isn't so fond of types (?) is there some good reading on this philosophy i can look at?
19:54:47
rustisafungus
so you guys do like your variables to be strongly typed? i think there is some quote from pg saying that values have types, not variables
19:55:39
Xach
there's some joke in there to be made along the lines of "if trees could scream, would we be so cavalier about cutting them down? maybe if they screamed all the time, for no reason"
19:56:12
|3b|
though telling the compiler we will only put values of a specific type in a particular variable can allow some nice optimizations, so we do that sometimes
19:56:57
rustisafungus
"values have types" sounds equivalent to "i dont like declaring a variety of different variable names when i could just have one"
19:58:27
|3b|
if you like, you can just say we default to all variables being strongly typed as T (which is the type in CL that is a supertype of all other types), so can hold any values
19:58:45
aeth
The language surrounding types is really confusing. But "strong vs weak" afaik is normally about coercively typed languages being "weak", while in CL, there really are only rules for autoconversion within the numeric tower (e.g. (+ integer float)) afaik.
19:59:17
aeth
Where the canonical problem with weak types is 42 + "4" which could be "424" or 46 (or, really, anything else)
19:59:46
aeth
rustisafungus: if you want to be careful with your floats, you end every literal with "f0" or "d0" depending on which type you want. It's not that bad.
20:00:12
aeth
And, yeah, you can get wrapping integers, but only if you wrap them in an operation that wraps them, such as MOD
20:00:19
rustisafungus
aeth: idiomaticity is important in programming languages imo, i want all my libraries etc to treat floats as being radioactive
20:01:21
aeth
rustisafungus: every library that's worthwhile will use the "f0" suffix for all single-floats and the "d0" suffix for all double-floats with no exceptions. Once a float, things stay as floats, although they turn into the one with the highest precision if you mix them iirc.
20:03:21
aeth
rustisafungus: The rules are very consistent. An integer is a fixnum or a bignum. It becomes a bignum automatically if it leaves its range, but you can keep it in range to keep it efficient (with e.g. MOD, which might be optimized to the appropriate asm + instruction if the right size)
20:04:23
rustisafungus
yes but i could write a program where everything is some kind of String, and that would be all statically typed
20:04:24
aeth
rustisafungus: Division of an integer with an integer produces a rational, which is conceptually like a pair of bignums. Certain operations like SQRT that produce irrationals can turn something into a float (the one part I don't like, tbh), but otherwise, floats are only obtained by mixing something with a float, in which case it uses the most precise float.
20:04:50
aeth
And any of these numerical types can become complex (e.g. you can have a complex with integers, or a complex with any float type)
20:05:02
rustisafungus
but really i should be defining more about my values to my compiler, so i say "strongly" to distinguish the fact that i want to reveal as much as is practical about my program operation to my compiler, because it is smarter than i am, often
20:06:19
aeth
rustisafungus: CL numerical programs are more... mathematical than most programming languages. An integer is a mathematical integer. If you want it to be an efficient machine integer, you better actually establish bounds algorithmically, or DECLARE it and hope it errors.
20:07:05
rustisafungus
aeth: yeah, but that means that my program is either total with bounds or not total and i have to pray
20:07:24
rustisafungus
i hadn't realized that duality until now,... i guess all variables need to be bounded in order to have totality
20:07:57
aeth
rustisafungus: Other programs tolerate incorrect behavior for efficiency, but CL perfers to either error or turn into a mathematical type that prevents it from being an error (e.g. sqrt can produce complex)
20:08:35
aeth
rustisafungus: You can however disable this for floating point and get the NaN/inf of other languages. You have to use float-features:with-float-traps-masked because the way to do it is not standard.
20:09:05
aeth
for better or for worse, most numerical programs (1) use floats and (2) disable the built-in safety of the language this way.
20:11:06
aeth
arguably, single-floats should never overflow because it would be more consistent with the language design if they just overflowed into double-floats just like fixnums overflow into bignums
20:13:14
aeth
In practice, though, if you care about your numerical type, you're going to statically type or check-type your code there... so your integer becoming a float because one float was passed in won't really be an issue.
20:14:44
user51
has anyone done any emulation in lisp? i'm specifically talking about intel 8080, i figured it would be a decent first project.
20:16:55
aeth
user51: to be efficient on this sort of thing... (1) use SBCL, (2) use structs whose slots have a :type or use arrays with an :element-type that can be optimized (mostly just various simple numerical types; test with upgraded-array-element-type first) or some combination of these
20:18:18
aeth
rustisafungus: I bet you that SBCL will beat its performance because it has had decades of work put into it, even though it's neither statically typed (although it is gradually typed) nor aimed at RT programming.
20:18:49
aeth
It is possible, though a bit hard, to avoid GC during the runtime by preallocating everything. SBCL gives you enough profiling information to do this.
20:20:47
aeth
Well, actually SBCL is statically typed, I'm underselling it. CL itself is just dynamically typed (values hold type information), but SBCL is doubly statically typed, with parallel declared-type and inferred-type information at compile time associated with variables (although it's often just T, since most CL code is ultra-dynamic)
20:21:58
rustisafungus
so i guess in contrast to haskell, mutation in lisp is very common/idiomatic etc?
20:22:33
|3b|
yeah, CL likes to mix lots of styles of programming, 'pure functional', 'mutate everything', OOP, whatever :)
20:22:49
aeth
The least painful style is probably a "mostly functional" style, where pure functions feed into mutable data structures, since CL is a very expression-heavy language.
20:23:52
aeth
If you're writing an emulator in CL, it'd probably look a lot like writing an emulator in C, though.
20:23:53
rustisafungus
i think part of my curiousity about lisp is the realization that type systems are just code which executes at compile time
20:24:24
user51
aeth: thanks. and yes, c is the language i wrote the emulator in originally, although since it's my first it had a bunch of iterations for improvements.
20:24:41
aeth
As far as low-level programming goes, you have structs of arrays available to you in CL, but you dn't have arrays of structs, since there's no way to make an array with that sort of memory layout... you'd just get arrays of pointers to structs.
20:25:15
rustisafungus
user51: do you understand the NES (all those opcodes etc) or do you copypasta them from some documentation?
20:36:09
rustisafungus
i just came across this, possibly nsfw https://ncatlab.org/nlab/show/Oberwolfach+HoTT-Coq+tutorial
20:37:59
rustisafungus
i like the idea that time is a side effect btw, this is a much neglected idea
20:55:47
PuercoPop
aeth: manardb is similar to an array of structs (a mmap'ed back collection of classes). The only thing it doesn't do is allow random-access iirc, instead it forces you to iterate through all the instances at once
22:11:50
sveit
hello. i have seen online the statement that SBCL runs on Android, but I haven't found a guide to compile it either on-device (through termux) or cross-compile. is anyone familiar with this? a naive attempt to compile on-device ran into problems with undefined C functions.
22:13:59
rustisafungus
i've made rustc compile and then compile a rust program on termux once, but it was very, very slow
22:15:56
rustisafungus
yeah but repl.it will run your code in a vm for free, if you are just playing around
22:16:53
rustisafungus
i don't see sbcl, but there's clojure https://repl.it/languages/clojure and whatever emacs lisp is: https://repl.it/languages/elisp
22:18:34
Nilby
I have sbcl running on my phone, but it's not android. I compiled ECL first then compiled sbcl with it.
22:21:09
no-defun-allowed
There is an Android app with ECL and an acceptable editor, but I couldn't get Quicklisp working with it IIRC
22:23:59
sveit
i tried to use i to bootstrap in the SBCL compile, but ran into the undefined C functions
22:24:34
sveit
the reason for doing this is not to run it on a phone, but a somewhat powerful tablet.
22:25:32
sveit
I can let you know in a second. if i remember the spelling right it was getdtablesize
22:26:04
sveit
commits like this one (there are others) seem to suggest this should be possible: https://sourceforge.net/p/sbcl/sbcl/ci/e84400d65cfd88483d901199b482bcb892a0ac28/
22:26:48
rustisafungus
i have no idea if this will photograph you while you are on the john and post the picture on the front page of a newspaper, but lisps are available on android,... https://play.google.com/store/apps/details?id=org.eql5.android.repl&hl=en_US
22:26:50
sveit
actually i have not just quicklisp, but SLY/SLIME working with ECL on termux. it's actually quite nice
22:27:03
no-defun-allowed
https://github.com/pocoproject/poco/issues/1204 suggests you should replace that with sysconf(_SC_OPEN_MAX)
22:28:50
sveit
no-defun-allowed: the first build i did had some error with sockets, so quicklisp didn't work, but it was from not including the argument --build=aarch64-linux-android to configure
22:29:53
sveit
i am happy to start patching, but i was hoping there was some cross-compile or other process i could do without modifying the source based on some of the mysterious statements on the internet :)
22:31:57
sm2n
sveit, if it's actually libc, you could maybe try compiling against musl statically instead
22:33:20
sveit
sm2n: thanks! long shot, but do you know what to pass to the SBCL make to do this static linking?
22:35:43
sveit
Nilby: only clang is officially supported, i think getting GCC will run into more problems than SBCL :)
22:36:59
sm2n
but it looks like threading is disabled on aarch64, so I think that means slime etc won't work
22:37:21
sm2n
here is the build script: https://git.alpinelinux.org/aports/tree/community/sbcl/APKBUILD
22:38:20
Nilby
searching reports this: https://github.com/its-pointless/gcc_termux . It looks pretty kludgy though.
22:38:53
no-defun-allowed
Well, threading on AArch64 does work, so it could be enabled. (I think you pass --fancy and you get all the good stuff including threading.)
1:10:24
drl
OK, I'm back. I deleted the old code in ~/.sbclrc. I also deleted ~/.cache/common-lisp/ and ~/.slime/fasl/. I closed and restarted emacs. But alexandria still can't load. The first line of the backtrace is: 0: (SB-IMPL::UPDATE-PACKAGE-WITH-VARIANCE #<PACKAGE "ALEXANDRIA.1.0.0"> "ALEXANDRIA" ("ALEXANDRIA.1.0.0" "ALEXANDRIA-1") #S(SB-C:DEFINITION-SOURCE-LOCATION :NAMESTRING "/home/l/quicklisp/dists/quicklisp/..
1:31:41
drl
|3b|, the file ~/.swank.lisp does not exist, but /home/l/quicklisp/dists/quicklisp/software/slime-v2.24/swank.lisp does exist.
2:03:29
drl
|3b|, if sbcl is started like this: sbcl --no-sysinit --no-userinit, and then * (load "alexandria") I get "Couldn't load "alexandria": file does not exist."
2:14:43
Alfr
And --no-userinit will also skip the bits that quicklisp set up for, not sure you want this, unless you've manually set up alexandria somewhere.
2:16:55
drl
Alfr, alexandria has been downloaded by quicklisp, but can't load. I just ran "sbcl --no-sysinit --no-userinit" because |3b| asked me to. Usually I use slime.
2:19:36
drl
(ql:quickload "alexandria") give this error message: ALEXANDRIA is a nickname for the package ALEXANDRIA.1.0.0
2:25:32
Alfr
drl, w/ --no-sysinit --no-userinit; did you try loading the setup.lisp file in the quicklisp directory and then quickloading alexandria?
2:35:51
drl
Alfr, Is this the correct way to load it?: (load '/home/l/quicklisp/quicklisp/setup.lisp)
3:02:10
drl
If sbcl is started without those options, then (ql:quickload "alexandria") loads without error.
3:04:23
Alfr_
So sbcl finds its contibs. Move your ~/.sbclrc somewhere safe and install quicklisp again with sbcl --no-sysinit .