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?