freenode/#lisp - IRC Chatlog
Search
6:13:36
russellw
When writing a Common Lisp program, are you supposed to put your main program code at top level, or in a 'main' function? From my experiments thus far, putting the main program code at top level seems to work when running interpreted but not compiled
6:14:33
Shinmera
typically you write you software as a library plus a singular entry function that you may call main or whatever else.
6:16:16
russellw
beach, okay, rather than get into terminology questions, let's pretend I didn't say that part; would you agree with Shinmera that main code should go into a function rather than top-level?
6:16:42
jackdaniel
having entry point has benefits: you may provide top-level error handler, unwind-protect, load necessary assets which are not part of the image etc
6:16:59
aeth
russellw: If I was writing it like a script, I'd do it Python-style and have a main function and then a call to main underneath it, like (defun main () ...) (main)
6:17:08
Shinmera
typically during development you'll want to call functions at your leisure and only reserve a main for when it's run standalone
6:18:53
russellw
aeth, I have tried doing that, but then when I compile the program with SBCL on Windows, the compiled program does nothing; (main) being top level code, is simply disregarded. It is possible to supply the (main) call on the compiler command line. Would this be considered a normal way to do it?
6:18:53
Shinmera
Having things at the top level removes the ability to choose whether you want to run the standalone startup
6:19:39
russellw
Shinmera, this is also a good point. So when compiling the standalone program, supplying the main call on the compiler command line, is that the recommended way to do it?
6:19:40
aeth
e.g. in Linux you add a "#!/bin/sbcl --script" to the top line (without quotes) and make the file executable
6:20:18
russellw
aeth, different scenario – I'm on Windows, trying to compile a version that can work without SBCL installed
6:20:24
Shinmera
russellw: if you generate a binary for deployment it'll ask you for an entry point anyway
6:22:35
russellw
Okay so the consensus seems to be that the source file should *not* contain (main). The source file should contain (defun main ...) and then the instructions to call (main) as the entry point, should be given to the compiler when compiling the standalone program. Would that be a correct summary?
6:29:47
russellw
How do you get SBCL to do something once the program loads? sbcl --script main.lisp --eval "(main)" doesn't do anything, but then, nor does sbcl --script main.lisp --eval "(print 123456)"
7:02:46
shrdlu68
I get a style-warning for (make-array n :element-type '(simple-array short-float 2))
7:03:34
shrdlu68
But then I also get a warning when I set :initial-element to (make-array 2 :element-type 'short-float :initial-element 0.0))
7:06:57
aeth
You want 0s0 or 0.0s0 for short float (f is single-float, d is double-float, and l is long-float... long-float is often the same as double-float and short-float is often the same as single-float)
7:11:51
aeth
You can do (upgraded-array-element-type 'foo) to see if it will become. Only character and bit are guaranteed (unless base-char also is?), but (unsigned-byte 8) is in essentially every useful implementation.
7:12:53
aeth
Nearly every one will have multiples of 8 in signed and unsigned, possibly up to 64 (even though that's probably larger than the fixnum size in 64-bit implementations) as well as fixnum. Most will have single-float and double-float. If short-float and long-float are part of the implementation, they're probably there, too.
7:15:59
aeth
Other integer sizes often exist. It will round up to the nearest one. e.g. (integer 0 5000000) becomes (unsigned-byte 32) everywhere I tested except SBCL, where it becomes (unsigned-byte 31)
7:19:01
aeth
Oh, and which multiples of 8 depends on the implementation, but probably 8, 16, 32, 64 (if it's a 64-bit implementation)
7:24:21
aeth
The tl;dr pattern here is that it's (in practice) basically all numbers, with the exception of characters (character arrays are strings)
8:08:59
aeth
Just by Github stars: 1666 stars. https://github.com/dimitri/pgloader ; 1071 stars. https://github.com/stumpwm/stumpwm ; 1513 stars. https://github.com/atlas-engineer/next ; 1483 stars. https://github.com/froggey/Mezzano
8:10:46
aeth
Then there's stuff that's indirect. e.g. https://en.wikipedia.org/wiki/Maxima_(software) is apparently a part of Sage, which is incredibly popular.
8:14:05
jackdaniel
shrdlu68: I think it is fair to say, that it is one of few applications written in CL which aim to be applications which are used without any knowledge about Lisp whatsoever
8:14:46
jackdaniel
so saying that pgloader is the most widely used program written in CL which targets audience outside the Lisp community could be accurate
8:15:24
jackdaniel
Shinmera: I suspect that the sole user of this CL code are google servers, users run javascript
8:15:56
aeth
jackdaniel: on the other hand, my .stumpwmrc is 6 lines, so even though it claims to be the Emacs of window managers, it falls short of that goal because I don't have to extensively configure it in Lisp to make it usable.
8:16:04
jackdaniel
but sure, that's debatable what counts as an application given a definition I've proposed
8:16:38
aeth
Shinmera: I almost mentioned Google Flights, but I don't think it counted in shrdlu68's definition.
8:19:56
shrdlu68
jackdaniel: Or server, really. So software like hbase, elastic-search would count too.
8:21:59
shrdlu68
Shinmera: I was just taking a look at the issue on the pgloader repo, and it occured to me that it might be the most widely used CL program.
8:25:37
aeth
You're probably not going to get too far with popularity in desktop software without graphics. If I had to guess what has the most potential there (especially if you ad "outside of the Lisp community" as a qualification) it would be a game. There are probably at least 6 game engine projects right now.
8:27:50
no-defun-allowed
what persistent object storage should i use? elephant's not on quicklisp but it seems exactly what i want
8:28:03
no-defun-allowed
postmodern can make clos instances transparently which is also a good point
8:28:35
shrdlu68
"Opusmodus is currently the most advanced software for computer-assisted composition available."
8:35:16
aeth
shrdlu68: pgloader might have the most issues reported for a CL program that's not an implementation.
8:40:26
no-defun-allowed
pgloader issue #12345: "node port when pls i dont know lisp but i want to help"
8:45:27
Shinmera
Me writing a ticket to Microsoft: when r u goin to rewrite windows in lisp i wanna help
8:47:45
Shinmera
lindows was a linux windows thing that got sued for the name, if I remember correctly
8:49:18
Shinmera
anyway, I wouldn't be surprised if Lisp is used internally somewhere in quite a few companies
8:50:57
aeth
I can assess Lisp's popularity. It's very popular. My experience might be skewed, but most of my experience is with my Lisp projects.
8:52:45
no-defun-allowed
lisp is only used by one person in this house and there is only one programmer
9:04:06
no-defun-allowed
if lisp can abstract all the pain from maintaining databases there's possibilities for another 25 lispers at school
9:24:43
jackdaniel
https://gitlab.common-lisp.net/dkochmanski/metering this is a profiler written in CL
11:59:01
_death
gitlab requires javascript to view static text.. github getting worse day by day.. recently I noticed that followers and then repos are no longer ordered by date of last update.. I expect they'll continue to gimp it down.. so everything is basically terrible
12:01:11
oni-on-ion
aha! i can use M-x eww for github views, even syntax color it; MS is going to try to "do a facebook" with it.
12:01:55
oni-on-ion
that is how i see it. MS always copying stuff and github purchase was perfect to buddy on a social platform. cant wait for windows only featurez
12:32:36
russellw
The standard library function sublis, takes an expression and performs variable substitutions from an alist. I need to write a variant version that performs iterated substitution for an alist returned by unification that e.g. maps x->y->z. The code is easy to write, but what would be an idiomatic name for the new version? sublisr for the recursive version? sublis* for an extended version?
13:44:13
pfdietz
"Other integer sizes often exist. It will round up to the nearest one. e.g. (integer 0 5000000) becomes (unsigned-byte 32) everywhere I tested except SBCL, where it becomes (unsigned-byte 31)"
13:54:59
yrk
why is clsql refusing to build on my machine? "Ensure that you have multiarch i386 build tools and libraries if you want to build 32-bit library"
15:22:36
francogrex
an someone give me pointers as to how investigate and correct this problem here, it's doing my head in: https://pastebin.com/Ke1rXaVN
15:23:30
francogrex
I had no problems in a previous version of that library, but the new one causes errors
15:26:36
francogrex
but the stepping is not that fine-grained and it kinda skips over large parts, so I am not able to understand what is the undefined alien function that is the error
15:38:14
jkordani_
if you've changed your debug level, you will also need to purge all fasls and recompile with those settings
15:41:13
jkordani_
francogrex: mmm.... I wouldn't be surprised if debug declarations are also honored for interpreted code
15:42:11
jkordani_
ccl doesn't have an interpreter for example, so everything is compiled. Even if you used load-source-op, fasls would still be created
15:44:09
francogrex
i could have used it to compare otherwise. in any case though the code runs fine on ccl, it's the library's interaction with sbcl that is problematic
15:44:30
jkordani_
and also if you're relying on ql libraries, it is possible that loading them also causes a compilation, even if your own script is not compiled
15:45:35
jkordani_
but i'm making assumptions here, I would be curious to know if your system has cached fasls around, unless you've made pains to ensure that no compilation is performed on any code your code depends on
15:49:08
jkordani_
there are some things to know to get sbcl to produce the debug output you'd expect but I can't find the specific info at the moment. And gdb is only as good as the optimization settings and debug symbols it can find ;-) trust me I'
15:49:26
jkordani_
ve wasted so much time trying to figure out why I can't see some local here or there
16:37:14
phoe
Is it possible to send binary data inside Lisp strings, as long as I escape the #\" and #\\?
16:38:10
dlowe
the answer is "other people will hate you if they have to deal with this crap in their code"
16:38:39
jasom
The easiest way to handle binary data in strings is to use iso-8859-1 when serializing, since all modern implementations use unicode, that means char-code will be the byte that ends up on the line
16:39:08
jasom
however, there is the issue of line-endings. Many lisps on windows will default to converting #\Newline to #\Return #\Newline on output
16:39:45
jasom
last I checked, all but one (CCL I think?) lisp had a way of specifying the line ending in the external-format, so it is motsly soluble
16:41:57
jasom
On many implementations strings are far faster than byte vectors, perhaps counterintuitively. If you only care about some subset of (SBCL, CCL) then fast-io is probably a better bet, since CCL can't do binary strings on windows correctly and fast-io is only rarely slower (and sometimes faster) than using strings on SBCL.
16:42:50
jasom
As far as doing things that are mixed ascii and binary (many formats work this way) I find the best of the bad choices is to use #. to conver the string to binary at read-time.
16:46:20
jasom
phoe: if you have "mostly text" formats that may contain a small amount of binary information, then using iso-8859-1 is by far the easiest way, except windows/ccl just won't work
16:47:40
asarch
I was reviewing the bodyless Fibonacci computing loop: (do ((n 0 (+ 1 n)) (cur 0 next) (next 1 (
16:48:34
jasom
asarch: I tend to avoid DO since it's a pain to remember that many positional arguments in a control-flow macro
16:50:13
asarch
Common Lisp would be great in this cases: https://www.youtube.com/watch?v=jvIzIAgRWV0
16:52:14
jasom
jkordani_: good to know; I may be misremembering the implementation, or it may have changed in the past 10 years.
16:54:21
jkordani_
jasom: https://ccl.clozure.com/docs/ccl.html#characters-and-external-formats but note that *default is unix, even on windows
16:55:36
jkordani_
I seem to remember having to change *something* else in order to get it to work the way I wanted on ccl though so I don't think you're wrong
16:55:54
jasom
phoe: disregard what I said about CCL, feel free to use binary strings and an iso-8859-1 encoding, though others may hate you (I got more pull requests to change to using byte vectors than I have gottent total pull requests on all other lisp projects I've ever put on github).
16:56:46
jasom
and I eventually switched to fast-io, as it was within an order of magnitude of the speed of strings on all implementations except CLISP
16:57:53
jasom
when your string functions are compiled hand-optimized C and your byte functions are only slightly optimized byte code interpreted, there's no escaping the performance gap.
16:59:34
jasom
I also had 2 different people suggest using offset vectors instead of copying subvectors out both citing "performance" and both obviously never having actually benchmarked the difference...
17:00:19
jasom
I don't know if it's gotten better, but at the time simple-array was several times faster than non simple-array on sbcl.