freenode/#lisp - IRC Chatlog
Search
15:46:03
Josh_2
I have :export in defpackage and am export two symbols "wait-to-play" and "setup-x-control" but this always says these functions are not external to to my package Q_Q https://plaster.tymoon.eu/view/1355#1355
15:48:32
sjl_
But by default, the lisp reader will uppercase symbols when it reads them. So the symbols you're trying to access in lines 22/23 are named "SETUP-X-CONTROL" and "WAIT-TO-PLAY"
15:50:16
sjl_
You're already using uninterned symbols for the package name and in the :use, you could just do the same for the :export list.
15:58:00
vms14
I have troubles while designing, and I guess with bottom up design will be easier than what I'm used to do
15:59:29
sjl_
it takes a little while to get used to, but once you do it's pretty nice to work with. there are just a couple of annoying edge cases that newbies often hit.
15:59:33
vms14
The program I don't know how to design is some kind of forum with hunchentoot, to learn lisp and backend at same time
16:01:21
vms14
bottom up design suggests start to creating functions like "create-post" "create-user" and go abstracting step by step?
16:02:12
Josh_2
https://plaster.tymoon.eu/view/1356#1356 I have that file which is called save-image.lisp I load it in sbcl from term run (save) it produces the executable I use ./server it then returns instantly
16:03:52
Josh_2
vms14: http://dept-info.labri.fr/~strandh/Teaching/PFS/Common/Strandh-Tutorial/bottom-up-programming.html
16:06:05
Josh_2
just like if u learned CPP as first language OO is probs how you think about a problem naturally
16:08:09
sjl_
Josh_2: I'm not sure exactly what you're trying to do, but often people distribute binaries in CL by doing something like:
16:08:11
sjl_
1. Run Lisp on your machine. 2. Load all your code into that Lisp process with ASDF, Quicklisp, whatever.
16:08:13
sjl_
3. Use save-lisp-and-die with :toplevel 'mypackage:foo to produce a binary that will call the function mypackage:foo when it's run.
16:08:15
sjl_
mypackage:foo would initialize any variables/whatever that depend on the computer it's being run on, and then it would do the actual useful thing you want the program to do.
16:08:49
vms14
as for a program that creates a forum, I should start by functions like "create-post" and go creating functions from that
16:09:37
vms14
and don't think about implementation until I'm on the step that needs to be implemented
16:09:46
sjl_
In your snippet, I don't know why you're calling (load-up) twice, the in-package isn't necessary and/or helpful, and I don't know why you're calling sb-impl
16:22:10
Bike
i mixed up something obvious and string< doesn't work like i thought, so, is there an easy way to sort a list of strings in lexicographic order?
16:25:29
Bike
well, what i'm actually trying to do is sort a list of (symbol ...) by the symbols, by sorting the package first and then the symbol names
16:25:56
Bike
so i'm sorting with (or (string< (package-name (symbol-package s1)) (package-name (symbol-package s2))) (string< (symbol-name s1) (symbol-name s2)))
16:26:06
Josh_2
sjl_: okay that worked, but now my executable just shuts instantly, is there a function I can call to take my to the sbcl top-level?
16:26:31
sjl_
Bike: you need to have another check for string< p2 p1 before you move on to compare the symbol names
16:27:09
Josh_2
the function I call 'x-control:setup-x-control sets up the params and then calls the main function, however that function works in the background on seperate threads
16:28:23
sjl_
at some point I wrote a compose-predicates-for-sorting function but I can't remember where I put it
16:30:51
dlowe
(also, they couldn't be simple predicates without some annoying duplication of effort
16:32:37
sjl_
Josh_2: Ah. Do you actually WANT the REPL, or do you just want the thing to not immediately exit?
16:35:21
sjl_
Then sb-impl::toplevel-init might work. Unfortunate that it's not exported/part of the public API
16:36:35
sjl_
You can use it, you just don't get any promises from the SBCL folks that they won't rename it or change it in the future.
16:37:11
sjl_
Not if you don't WANT it to go into the REPL after. In your case you do, but for other programs you might not.
16:39:22
sjl_
I suppose you could make everyone that DOESN'T want the REPL call (sb-ext:exit :code 0) manually, rather than making the people who DO want the REPL call the REPL function.
16:43:04
Josh_2
I'd have a functional phone computer mouse if I could get clx to click and unclick :(
16:55:51
Josh_2
Heres another question. CLX comes with a folder called "extensions" but the functions contained within aren't callable with (xlib:fake-motion-event ..) for example
16:56:30
sjl_
Bike: dlowe: from memory I think it was something like this https://plaster.tymoon.eu/view/1357#1357
16:59:25
dlowe
if you have a comparison return :< :> or := then you could compose them much more efficiently
17:53:02
pjb
Bike: one instance in quicklisp: ~/quicklisp/dists/quicklisp/software/mcclim-20190307-git/Libraries/ESA/utils.lisp:460:(defmethod make-instance ((class modual-class) &rest initargs)
17:55:00
katco
i think i've found my issue, but i'd appreciate some discussion! `:cffi-libffi` is the system which contains the `(defctype :sizet size-t)` [here](https://github.com/cffi/cffi/blob/master/libffi/funcall.lisp#L130-L132). this system is only loaded when gsll's asd file is loaded [here](https://gitlab.common-lisp.net/antik/gsll/blob/master/gsll.asd#L21-22). because guix performs a `asdf:compile-bundle-op` to generate a fasl, and
17:55:01
katco
then generates a new asd file to point to the `--system.fasl`, the `eval-when` in gsll never gets called. my question is: why does gsll load `:cffi-libffi` this way?
17:58:02
katco
addendum: the `eval-when` only gets called when the `asdf:compile-bundle-op` is performed, but not on subsequent loads of the fasl, which is why there are no errors at compile-time, but there are at load-time
18:00:08
katco
pjb: i have a minimal test case, and it doesn't. gsll's asd file is out of the picture by the time the fasl is compiled, and a user or consumer system is loading the `--system.fasl`
18:00:09
Nilby
katco: I think software that uses cffi should define its own size-t type if it needs to and not use on the one in cffi-libffi
18:01:47
Nilby
Bike: https://github.com/johanlindberg/lisa.git uses the defmethod of make-instance trick
18:02:08
katco
pjb: mind you, this is a unique property of how guix packages things. it has little to do with how this would work with say, quicklisp, which loads the original asd every time
18:02:34
katco
Nilby: i was reading some discussion around that, but alas, i am merely trying to package gsll, not modify it (atm)
18:04:18
katco
Bike: and yes, asdf's "best practices" doc says not to define code (let alone macros) in the asd. i am wondering what's behind that stance, and also why a package author would choose to rely on cffi-libffi in this manner and not through `:depends-on` or something
18:06:35
katco
if behavior is needed at runtime as it is with gsll, this breaks anything trying to deal in fasls, and not source
18:08:00
katco
Bike: in your experience, would this warrant filing an issue? i do see this "pattern" a lot. i wish someone could tell me why people use it. i'd like to understand it better.
18:11:37
katco
i am assuming i'm missing some nuanced interplay between cffi and this package. liam is involved in both, and there was an email thread discussing the removing of `:sizet`
18:14:15
katco
LiamH: hi, thanks for the packages. i'm trying to package it into a linux distro called guix, and i was having some issues related to what we've been discussing
18:14:56
katco
LiamH: no worries. would you mind reading the last bit of backscroll, or would you like a summary?
18:17:54
katco
basicaly, the way guix compiles/packages lisp systems is by doing an `asdf:compile-bundle-op` and then generating its own asd to point to the pre-compiled `--system.fasl`. this causes issues when there is functionality needed at runtime defined in systems' `.asd` files (as is the case with gsll). in this case, gsll compiles fine, but then if you try to use it, it errors saying cffi has no `:sizet`. as you know, this is because
18:17:54
katco
it's defined in `cffi-libffi` which is loaded in gsll's asd file, which guix doesn't see when loading the fasl.
18:19:36
katco
asdf's "best practices" doc says not to add code into the asd file, so i was wondering (1) why do packages do this (2) specifically why does gsll do this instead of specifying `cffi-libffi` as a dependency?
18:20:11
Xach
katco: the best practices are recent and the system files were often written when there was no better option to accomplish certain goals.
18:20:35
Xach
i believe asdf has better ways to do things now but old system files are not always updated.
18:21:26
LiamH
I am trying to recall exactly why it's done. As Xach says, it's been a while since I wrote that - about a decade.
18:22:28
katco
no worries if the reasoning escapes you :) one of the reasons i love CL is that i can pick up libs written long ago, and they're still useful
18:23:19
LiamH
Without finding the reason yet, I'd say if there is now a better way to do this, I'm more than happy to make or pull the appropriate change(s).
18:24:52
sjl_
this is the commit that introduced the eval-when. Commit message doesn't mean a lot to me, but maybe it can jog LiamH's memory :) https://gitlab.common-lisp.net/antik/gsll/commit/121e475d13f2bb854a9a9dc35d615f8402bc7647
18:25:02
katco
that would be great. unfortunately i don't know what the better way is as i'm unsure what this is trying to accomplish
18:25:24
LiamH
Here's what I remember, looking at my comment "loads cff[i]-grovel too, needed here": If I tried to make a dependency, even :defsystem-depends-on (which is set), it would not get the grovel code.
18:27:15
katco
guix has facilities to modify code before compiling; let me try that ^ on my end, and i'll ping you?
18:27:26
LiamH
Well the defsystem-depends-on is already there. So just try removing the eval-when and see what happens.
19:23:30
Nilby
p_l: as a programmer I used clsql as an ETL tool, but I had to write the transform part myself. ETL tools are mostly GUI to write what would be a function. Unfortunately it's hard to have non-programmers do your data cleaning for you, if you don't make them a GUI.
19:33:38
Nilby
Unfortunately, years later, the ETL got outsourced to a bank who did a crap version in SSIS or something :( , probably because nobody could understand WTF I was doing in Lisp.
19:34:52
p_l
that's one part of it, another is that the bank probably outsourced it to idiots who made crappiest SSIS possible
19:46:52
defunkydrummer
i have also seen the horrible SSIS packages unexperienced people create when given the tool
19:47:26
defunkydrummer
"ETL tools are mostly GUI to write what would be a function" --> Basically, this.
19:48:38
defunkydrummer
now you have tools like Alteryx, in which an inexperienced person, after receiving a full course in Alteryx, can be able to create in a full one or two hours of clicking and clicking through menus, the equivalent to a few dozen lines Python script.
19:49:59
p_l
defunkydrummer: for what its worth, that few hundred lines of python better not have cpu-bound points
19:50:35
defunkydrummer
minion: memo to iarebatman: you wanted a function to traverse nested property-lists (plists). I have one here: https://gist.github.com/defunkydrummer/011c66f40a52977c2b33a1671bd5af0c. Enjoy.
19:51:03
p_l
defunkydrummer: I had to babysit a script once which was technically a transform script from pcap to CSV
19:51:16
minion
iarebatman, memo from defunkydrummer: you wanted a function to traverse nested property-lists (plists). I have one here: https://gist.github.com/defunkydrummer/011c66f40a52977c2b33a1671bd5af0c. Enjoy.
19:53:55
defunkydrummer
iarebatman: "TELL ME NOW SLAVE BOT"---> rofl!! So, why do you need to create plists that are so nested?
19:54:10
stylewarning
defunkydrummer: let's write a new quicklisp library where everything is written in spanish
19:55:08
defunkydrummer
stylewarning: i'd better write some lyrics and you can add music to them in your brand new yamaha SK-7
19:55:11
iarebatman
And I’m new to CL, with a tiny bit of Clojure experience - so their get-in macro came to mind
19:55:35
defunkydrummer
stylewarning: or we can create in spanish, a ML dialect embedded in common lisp, and call it "TONELADA DE CARBON"
19:56:00
defunkydrummer
awww sorry!! SK is a line of yamaha synths, my brain played neural network jokes on me
19:56:31
defunkydrummer
spanish is my native language, i'm from <redacted out>, same city as PuercoPop
19:57:40
defunkydrummer
so, iarebatman , welcome to the wonderful world of Common Lisp, now with 100% less underlying Java
19:59:24
defunkydrummer
stylewarning plz contribute more memes to LispMemes, it's a moral imperative to satisfy the hunger of the Lambda Calculus gods. I admit the quality of my own memes have declined a bit.
19:59:53
iarebatman
That’s definitely a huge plus in my book - I was ecstatic when I discovered CL was actually still used by people and that I could build native executables with it!
20:00:20
defunkydrummer
iarebatman: if you check the (english) documentation of "getf*", you'll see it will also pick up lists of plists, which is useful.
20:01:03
stylewarning
defunkydrummer: i'm giving a lisp talk at a julia meetup saturday so i need to prep some
20:01:49
iarebatman
Thank you for the gist defunkydrummer, I will have to take a look later tonight when I get to work on my personal stuff
20:02:06
defunkydrummer
iarebatman : yes, however note that modern lisp implementations are going to compile your functions to machine language anyways, so you'll get no speedups when producing an executable. In other words, if you are looking for creating an executable only for a potential speedup, it isn't needed at all.
20:02:47
defunkydrummer
phoe: Xach doesn't know the benefits of our job compensation plan: 1. Free Space Cadet Keyboard
20:03:14
iarebatman
Naw, I simply enjoy being able to hand a stand-alone executable to someone that they can run without a bunch of dependencies
20:03:47
defunkydrummer
iarebatman: yes, but note that the dependencies will "be there" in the form of a gigantic executable size
20:04:35
iarebatman
I ran “strip” on my buildapp test and it was around 200KB. That seemed reasonable to me
20:04:41
defunkydrummer
because they will need to be loaded in the Lisp image for your system to work. When producing the executable, this effectively means embedding that image into the executable. Unless you use an implementation like Embedded Common Lisp (ECL) which is able to do all kinds of magic.
20:04:44
katco
LiamH: well, it appears as though as of asdf v3.2, `:defsystem-depends-on` does not do what we think it should do in this case. it can't find `CFFI-GROVEL` despite it being in `XDG_DATA_DIRS`: "READ error during LOAD: Package CFFI-GROVEL does not exist."
20:05:32
defunkydrummer
SBCL and you got 200KB? ummm are you from the future? tell us, did we solve global warming?
20:06:01
katco
i can correct my guix package by also specifying `:cffi-libffi` in the `depends-on` clause, but i remain unsure what the correct way to do something like this is...
20:06:42
defunkydrummer
although i havent "stripped" a binary before. I rather stay with my clothes on.
20:08:16
Bike
trying to understand the asdf manual... it might say that you can just have :grovel-file instead of cffi-grovel:grovel-file
20:08:29
stylewarning
defunkydrummer: I think I'm just going to sit there projecting emacs saying "this is how you debug problems in lisp, maybe u should consider this in julia"
20:10:19
iarebatman
yup - so great news - it DOES reduce my 38MB hello world CL program down to about 270KB
20:10:42
defunkydrummer
stylewarning: it would be nice if Julia was a pathway drug to Common Lisp... "if you like Julia, you'll love CL. It will make you feel like Rick James"
20:10:53
Bike
https://common-lisp.net/project/cffi/manual/html_node/Groveller-ASDF-Integration.html okay now THIS should be helpful, katco
20:11:16
katco
iarebatman: i recall having success with `:compress` options in sbcl. ~1-2MiB binaries i think? been awhile
20:11:53
stylewarning
defunkydrummer: unfortunately, given that it's Literally Impossible (TM) to interactively plot data in Lisp, and it's Literally Impossible (TM) to do any real world linear algebra, nobody in the Julia community will be converting to Lisp. :[
20:12:36
phoe
stylewarning: the only thing that's literally impossible in Common Lisp is fitting it on a microcontroller
20:12:37
iarebatman
sigh - well 38MB files aren't awesome for sure - I thought I had hit the jackpot here. you guys sorta bummed me out and now I'm a sad panda =/
20:12:44
defunkydrummer
iarebatman : if you are looking for small binaries, don't use SBCL. I mean, you can reduce the binary size by enabling compression when using save-lisp-and-die. If smaller binaries are required, CLISP produces smaller ones. If ultimate small binaries are required, ECL will compile your Lisp code to C and can produce reasonable sizes. Or if you hav
20:12:57
phoe
the rest is a matter of the Borg^W^W absorbing enough of the other paradigms to be able to emulate them
20:13:00
stylewarning
katco: Well the capitalization and TM were sort of jokes, but right now, Lisp isn't suitable for the kind of thing the usual scientific programmer wants to do.
20:13:05
dlowe
iarebatman: the nice thing is that if you make a huge app, it probably will only bump it up a few MB
20:13:34
MichaelRaskin
Also, there are some things that are cleaner in Julia from the language point of view
20:14:24
katco
stylewarning: i definitely got matplot histograms out on my first day of trying. i'm working with linear algebra and data science libs right now
20:14:33
stylewarning
defunkydrummer: even MAGICL, which was supposed to be good, just hasn't had the time to actually be good.
20:14:48
defunkydrummer
stylewarning the other hand... and i'm going to be a SmugLispWeenie here, if suddenly CL had the same support for "data analysis" and "data science" as Python, we would have a huge influx of people adding very low quality libraries to the ecosystem. Which is what is happening with Python now.
20:14:50
stylewarning
katco: well if you want to chat/want guidance/collaborate/etc., i'd be happy to
20:15:01
phoe
dlowe: brief googling tells me https://gist.github.com/burtonsamograd/f08f561264ff94391300
20:15:27
defunkydrummer
dlowe: please call the function "shake-shake-shake" like the LW guys did, or "shake-yer-booty". Or you can call the project: SHEIK YERBOUTI
20:15:38
katco
stylewarning: i would definitely be interested in chatting and or guidance. i'm using CL to learn data science and ML stuff
20:15:38
iarebatman
I mean that makes me feel just about as icky as bundling up a node project or a python project with virtualenv and a bunch of deps. I guess at least in this case there are possible solutions..
20:16:02
stylewarning
dlowe: phoe: We used a more "up to date" version of this before... See %ZAP-INFO: https://github.com/rigetti/quilc/blob/master/app/src/impl/sbcl.lisp
20:16:31
defunkydrummer
iarebatman the situation in CL doesn't get remotely close to the horrible mess that is the NPM module system.
20:17:38
defunkydrummer
stylewarning uses windows!! suddenly i don't feel alone!! We're two now, two!!!
20:17:58
stylewarning
defunkydrummer: no, i just have to build our sdk on windows, which is housed in some VM somewhere :[
20:19:19
stylewarning
katco: it provides relatively no-nonsense bindings to BLAS/LAPACK and another fortran lib called expokit for matrix logarithms and exponentiation
20:19:45
stylewarning
katco: but the high-level library part of it is really poor and lacking, and deserves to be redesigned. There's also a decent einsum macro.
20:20:06
defunkydrummer
dlowe: don't measure binary size by using "hello world" programs, that doesn't make too much sense. Considering that CL is able to generate code and compile it at runtime, for a complex program, or even a slightly complex/big program, binary sizes will be totally alright.
20:20:30
katco
stylewarning: cool. i'm not really in a position to comment on utility yet as i'm just starting out. my focus is ML stuff
20:21:02
katco
stylewarning: and my immediate focus is data exploration prior to building a ML model. cl-ana seemed like a good fit for that
20:21:30
iarebatman
yay my CL book came in: Common Lisp: A Gentle Introduction to Symbolic Computation
20:22:16
phoe
in case you have programmed, it might be a little bit too gentle - but let's see what you think after the first few chapters
20:22:21
defunkydrummer
dlowe: It doesn't make sense for practical purposes. Nobody uses a language like Lisp for "hello world" programs. If your goal is the ultimate small hello world, you just create a shell script that prints Hello World. Or use assembly language to put "Hello World" in a memory location and jump to the OS function that prints it out... In any case, y
20:22:21
defunkydrummer
ou CAN do a small hello world in Lisp by using Embeddable Common Lisp (ECL), which will compile it to C and then produce the binary.
20:22:53
phoe
by the time it comes to deployment we're already doing docker shit that weighs hundreds of megabytes in total
20:28:59
defunkydrummer
dlowe : fair. But IMO that test would only show the size of the runtime and the presence/absence of a tree shaking mechanism
20:50:11
stylewarning
dlowe: to be clear, there shouldn't be a magical tree shaker, there are tradeoffs to what gets shaken out
21:25:15
aeth
Am I being naive if I store an immutable graph like this? 1 <-> 2 <-> 3 and 1 <-> 4 would be #(2 4 1 3 2 1) and #2A((0 1) (2 3) (4 4) (5 5)) where the 1D array is the connections and the 2D array is essentially the key that says what range the (n+1)th element is in (since the graph here starts with 1)
21:29:41
aeth
I'm not using lists because of random access, e.g. I can look up an item (and there might be thousands) as (subseq connections (aref range (1- item) 0) (aref range (1- item) 1))
21:31:08
aeth
(Except subseq is probably unnecessary in every actual use because most sequence functions have a start and an end, which is why I'd be storing the start and end)
22:33:22
grewal
aeth: why do you need two arrays instead of one? You can just store the nodes each node is connected to. Using your example, something like #(#(2 4) #(1 3) #(2) #(1))
22:37:28
vms14
(defclass meh () ((oh :accessor oh))) this won't let me push on this slot unless I put :initform nil
23:06:13
aeth
grewal: You can't, rows have to be the same length. I could pad it with -1s (or 0s, if I keep them starting at 1) but then I wouldn't know where they end ahead of time
23:06:39
aeth
grewal: It would also be better to use fake 2D arrays rather than actual 2D arrays, so sequence operations could be used with start/end.
23:15:15
grewal
aeth: I didn't use #2a. It's a vector of vectors, not a multi-dimensional array. Ultimately, the two approaches are probably the same under-the-hood, but your approach just seems a bit oblique
23:17:14
Bike
defstruct does not initialize to nil. it's undefined, which is worse than defclass, because if you read an uninitialized structure slot anything could happen
23:20:10
aeth
grewal: I think my solution scales better because two specialized arrays are going to be more efficient than a T array of specialized arrays because the GC will afaik have to iterate through the T array, but not the two specialized arrays.
23:32:25
White_Flame
aeth: more efficient would be to ensure the GC isn't triggered often, and use the most appropriate data structure regardless of its latency effect on GC
23:59:02
vms14
so the way is try to control when the gc is triggered and minimize as possible the work of the gc
23:59:43
aeth
vms14: of course you can't actually not allocate, so it's more choosing where to allocate... so preallocate
0:01:27
aeth
vms14: (defun foobar () (let ((foo (make-foo)) (bar (make-bar))) (do-some-fancy-game-loop foo bar))
0:01:58
aeth
vms14: And the bindings in do-some-fancy-game-loop aren't allocating (well, probably aren't)
0:05:38
aeth
vms14: This is a very Java-oriented way of saying "reuse buffers" like White_Flame said earlier. https://en.wikipedia.org/wiki/Object_pool_pattern
0:29:42
aeth
Me? I've never heard of that before. The website link is dead. This appears to be the source. https://github.com/ilitirit/manardb
0:30:22
aeth
I know a lot of people are proud of being able to use old libraries in Common Lisp, but I'm not sure I'd use a database that hasn't been updated in 10 years.
0:31:56
aeth
There's a handful of things that are just inherently really hard to write: operating systems, web browsers, databases, office suites, IDEs (and most content editors in general that are fancier than a basic text editor), game engines, etc.
0:32:59
aeth
Databases are pretty important, too, because you don't want your data to be corrupted or lost.
0:56:24
White_Flame
my first thought was actually destructuring-bind, but you'd still need to name intermediate value holders
0:56:50
vms14
also I should use :initargs instead of that bunch of setfs and will be even better than use pop
1:01:47
rtypo
i also tried sqlite last week, what i do differently is run every query inside 'with-open-database'
1:03:57
rtypo
i think i'm just paranoid with managing connections, since i'm bad at using databases :D
1:06:10
vms14
but I start by making first a simple forum, the most difficult thing is mantain data organized and know what kind of data I need
1:14:02
Nilby
I'm a terrible programmer, but that hasn't stopped me from writing 100k lines of semi-working Lisp.
1:14:29
vms14
I guess the better is to make a prototype and then write a new program taking that prototype as a reference
1:26:34
vms14
the comic is about the programmers having bugs, and those bugs evolve and end slaving the humanity, only lisp can save us
1:30:06
Nilby
After watching that video, I now realize I've been writing "Balance weasels on a rake".
1:54:05
equwal
So is there a way to generally reorder arguments to a function at compile time with a macro, based on the type?
2:01:42
Bike
if you really want to, you can usually get at the declared type information through semiportable mechanisms
2:51:27
no-defun-allowed
You could use a generic function and do something like (defmethod foo ((bar type) baz) (foo baz bar)), but that isn't "compile-time" and may cause fun call loops if baz is also type.
2:55:33
aeth
specialization-store does type-based dispatch at compile time IF there are type declarations. https://github.com/markcox80/specialization-store/