freenode/lisp - IRC Chatlog
Search
11:47:19
jackdaniel
(destructuring-bind ((a . b) (c . d)) (list (cons 1 2) (cons 3 4)) (list a b c d)) ; works
11:48:15
jackdaniel
(loop for (a . b) in (list (cons 1 2) (cons 3 4)) collect a collect b) ; also works
11:48:43
phoe
d-b won't work on reordered alists though, it can't perform this sort of pattern matching
11:49:24
jackdaniel
I'm certain I said that that it does not know anything about keys or values, hence - about the order ,-)
11:50:38
jackdaniel
flip214: you may put CASE in the loop to match keys, or alx:switch if keys have a custom test
12:02:13
kinope
Do any of the Common Lisp implementations support assigning threads to run on specific cpu cores?
12:04:05
p_l
kinope: I don't think there's anything explicitly made in Lisp-side APIs, but you can easily use CFFI to call out necessary system-level functions
13:13:46
luna_is_here
Can I use the same quicklisp installation folder for two CL implementations or will this cause problems?
13:16:45
jackdaniel
clisp has bundled asdf version which is quite old, old enough to make libraries not load
13:17:21
jackdaniel
either take asdf from upstream repository and load it instead, or use one of more popular implementations, like sbcl
13:18:06
luna_is_here
I usually use SBCL. I just want something less memory hungry (and faster startup) for some small scripts.
13:18:25
jackdaniel
I know that Fare put a lot of effort into upgradability, but 1. it is still broken, 2. it obfuscates asdf beyond compare :)
13:19:21
jackdaniel
but still, it compilicates things enormously, so if you can load desired asdf version upfront - simply do it
13:20:17
jackdaniel
ccl has smaller footprint, ecl even smaller (however startup and compilation time may be too big for you)
13:21:17
jackdaniel
last time I've checked all worked fine (-eish, clisp seems to be little neglected by library developers when testing)
13:24:42
jackdaniel
the reason is because Fare considered it important -- for system which runs for long time without downtime it may be desireable to be able to upgrade asdf to load some new software
13:25:46
jackdaniel
my opinion on this matter is that a build system should not be part of the final image (like you do not bundle make with your terminal application), and should be loaded only when it is needed (and unloaded / GCed afterwards)
13:25:58
terpri
seconding clozure common lisp (formerly openmcl) as an sbcl alternative. not much experience with ecl, abcl, proprietary CLs, etc.
13:27:24
jackdaniel
otoh, when not bundling it, someone may want to maintain a loaded software registry, so that may be duplicating the effort
13:27:48
terpri
i mostly use sbcl but it is a bit slow to start up and indeed a bit resource-intensive
13:27:49
jackdaniel
dlowe: no, that's not a next thing I'm going to say, please do not put words in my mouth
13:27:59
pve
jackdaniel: if you were able to unload asdf, would that effectively give you upgradeability as well?
13:28:26
phoe
pve: kind-of-in-theory, you'd also lose all information about already loaded systems though.
13:28:31
jackdaniel
dlowe: it might be, still quite provocative / not especially polite, especially that I've explicitly marked it as my opinion, not the "right thing"
13:28:41
terpri
(and i use clisp, but only for command-line hackery, mostly because it has gnu readline built-in...which is in fact *why* clisp is free software :P)
13:30:37
phoe
except via explicit state dumping/loading, not via UPDATE-INSTANCE-FOR-REDEFINED-CLASS
13:31:40
phoe
pve: dumping state, unloading ASDF, loading ASDF, and loading state is equivalent to upgrading ASDF in-place
13:31:48
jackdaniel
and it tries hard not to drop information which was stored at the "old asdf" runtime
13:32:15
terpri
fare was also at one point working on an asdf successor(?) called xcvb, dunno what happened with that
13:39:05
luna_is_here
Concerning readline in sbcl. There is linenoise (BSD license). Would it be hard to include that into sbcl, to get autocompletion?
13:42:34
jackdaniel
sombody somewhere sometime ago mentioned, that this library could use some love, but I don't remember details
14:09:24
ajithmk
Peeps who have worked with cffi, if a structure has a simple array inside it like four floats named vec4, how do I send it like this (setf (foreign-slot-value '(:struct blahblah) :vec4) 'whatcomeshere')?
14:10:12
ajithmk
I have tried '(0.0f0 0.0f0 0.0f0 0.0f0), #(0.0f0, 0.0f0, 0.0f0, 0.0f0) and (make-array ...)
14:12:13
jackdaniel
how about using (with-foreign-array (no-u-peep #(0x0f0 …) 'single-float) (setf (f-s-v <whatever>) no-u-peep))
14:15:39
jackdaniel
either way replace 'single-float with a valid cffi type and you should be golden (hopefully!)
16:11:26
contrapunctus
Y'all, what does #. mean here? 🤔 `(defrule inline #. (cons 'or %inline-rules%))`
16:17:28
contrapunctus
Well, I understand what it does. _Why_ the code is doing it is another matter entirely 😅
16:21:20
beach
Maybe if you try (read-from-string "(defrule inline #.(cons 'or lambda-list-keywords))") you will see it.
16:23:32
contrapunctus
Code in question, if anyone is curious - https://github.com/3b/3bmd/blob/master/parser.lisp#L450
16:39:18
contrapunctus
beach: oh, thanks, I got that 😀 I'm more puzzled about why the code opts to do this.
16:43:04
beach
phoe: But %inline-rules% is only used once, so it could have been inside the DEFRULE.
16:43:58
phoe
beach: https://github.com/3b/3bmd/blob/1e1ef9e59da537d75f455600210aac21c2ab5fa0/extensions.lisp#L88-L90
17:08:57
phoe
mokulus: you're asking this question on #lisp, answers will be naturally biased towards Lisp
17:10:37
phoe
Haskell is a strictly statically typed strictly functional language, whereas Common Lisp is a dynamically typed interactive multiparadigm language
17:12:18
phoe
it's much better suited for the interactive development style that's prevalent in the CL world
17:12:21
aeth
scymtym: You definitely can get god objects in CL. I wouldn't be surprised if some of the #lispgames game engines have them. It tends to be really common in that domain because there's so much going on every frame.
17:12:26
mokulus
I don't like it, because when I run a function I don't know what can I do with the result
17:12:44
contrapunctus
Isn't Lisp gradually typed though? Can add type annotations, tell compiler to type check at compile time?
17:13:11
Bike
technically there's no standard way to make declarations into assertions, but sbcl does it
17:13:40
phoe
mokulus: I guess that isn't lack of static typing though, that's poor programming style
17:14:44
aeth
ajithmk: If you create the array for the API (so not all APIs) you can use static-vectors to create a "bilingual" array that looks like both a CL array and a C array pointer. I think it requires you to control the allocation, though. https://github.com/sionescu/static-vectors/
17:15:08
phoe
aeth: static-vectors are allowed to be GCed and not GCed; depends on the implementation
17:15:29
phoe
so static-vectors' free function must be called for portability, even if it's a no-op on some implementations
17:15:46
aeth
phoe: No, I meant that I think that it requires an API like e.g. OpenGL, where you're providing the arrays.
17:16:59
mokulus
ok but why not have a type with the description? is this because the language is interpreted, so type mismatch would be an error anyway, that is types are only helpful at compile time?
17:17:26
aeth
Common Lisp is actually required to be compiled. Some have an interpreter for the REPL, others just compile to /tmp for each expression in the REPL
17:18:38
phoe
I guess that https://wiki.c2.com/?BenefitsOfDynamicTyping could possibly answer some of your questions
17:18:48
aeth
mokulus: If you're seriously deciding between Lisp and Haskell, though, you might want to consider Typed Racket, which is part of Racket (a Scheme) and is thus off-topic here. https://docs.racket-lang.org/ts-guide/index.html
17:19:35
p_l
though if you preserve semantics you can do full AST-level interpretation (LW allows that, among other things, useful for debugging)
17:19:37
aeth
p_l: I guess it's possible for a naive interpreter to exist past the macro phase, but does one?
17:20:15
p_l
aeth: CMUCL and SBCL both have one, though I don't know how well exercised they are (SBCL for a long time had the code commented out)
17:20:44
contrapunctus
mokulus: why not go through a Lisp book, make a moderate sized program in Lisp, and figure out for yourself whether or not you like it? 🤔
17:21:24
aeth
mokulus: Another statically typed Lisp is called "Shen". This actually compiles to Common Lisp so it's very marginally on topic here. https://github.com/Shen-Language/shen-sbcl
17:21:30
fwoaroof[m]
mokulus: so, since Haskell does type inference whenever it can, the textual representation of the program often lacks return types and stuff
17:22:27
puchacz
aeth: has Shen actually got anything to do with Lisp in addition to using it as a platform? I read about it and it felt like totally different language
17:22:58
fwoaroof[m]
Personally, I find working in Haskell feels like working in CL, except the compiler's more annoying
17:24:55
contrapunctus
stylewarning: hey 😀 I keep wanting to try out Coalton, but it all goes over my head 😓
17:25:53
fwoaroof[m]
Cool, my impression is that typeclasses are the worst part of implementing these sorts of type systems
17:26:57
contrapunctus
I've made a couple Elisp and Scheme programs, and I'm curious to see if type checking can provide any maintenance/tooling benefits.
17:27:08
fwoaroof[m]
Figuring out how to have them fall back to a generic function invocation, where feasible, would be interesting
17:27:31
phoe
contrapunctus: heavy use of type proclamations in SBCL can provide benefits thanks to its type inference engine
17:28:05
phoe
you can, and most likely will, get compile-time warnings in case the type inference engine figures out that there's a mismatch.
17:32:00
stylewarning
fwoaroof[m]: the trouble is of course a type class that is parametric on the return type
17:34:49
fwoaroof[m]
sm2n: the issue is that generics are only polymorphic on the types or the function's arguments
17:35:47
aeth
You could just make the first argument an ignorable variable representing the return type.
17:36:42
mokulus
which book would be the best for learning lisp? I'm familar with many programming languages, so it doesn't necessarily need to be simple
17:36:51
minion
mokulus: look at pcl: pcl-book: "Practical Common Lisp", an introduction to Common Lisp by Peter Seibel, available at http://www.gigamonkeys.com/book/ and in dead-tree form from Apress (as of 11 April 2005).
17:38:04
mokulus
would that be enought, or something after that? I guess getting familar with the hyper spec?
17:38:09
stylewarning
contrapunctus: maybe it does, but it’s too complicated and weird. In my opinion, call a spade a spade. If you’re going to write ML/Haskell, write it as it should, and provide a “foreign function” interface between ML and Lisp
17:38:56
stylewarning
(for something like Coalton, the hope is that the ML is embedded, and interacts with the lisp system as cleanly as possible)
17:40:18
fwoaroof[m]
Or, if you'd rather not use Emacs, the Atom or vim plugins might work, but they're more work to get started with
17:41:46
stylewarning
Not because you’re not a good enough programmer or because we can’t manage barebones setups
17:42:53
fwoaroof[m]
But, as nice as the commercial versions of Lispworks are, the PE is infuriating
17:45:04
fwoaroof[m]
Anyways, the prices make sense: it's a small company and they need to pay their employees
17:45:58
phoe
my personal opinion is that people like PG or ESR contributed to that fact by marketing Lisp as God's programming language that causes spurious enlightenment and is a magic wand and secret sauce and what not
17:46:41
fwoaroof[m]
You might not be able to get a job writing Lisp, but it improved how I write other languages
17:47:29
philweb
phoe: in fairness, back when they were evangelizing it... it was, relatively speaking (vs most other languages/environments)
17:49:17
stylewarning
mokulus: I wrote a draft article I hope to publish at some point that talks about what I think about lisp, “taking a step back”, and forgoing all the fluff of the 90s
17:49:46
fwoaroof[m]
Yeah: also, my impression is that the community today is a lot friendlier than it was 20 years ago
17:50:24
philweb
back in the 90's and earlier, other languages and environments had virtually none of the advantages of dynamic languages like lisp/smalltalk. so the contrast between them was very stark. over the last 20 years, many languages have picked off a lot of the features that used to be exclusive to dynamic languages (granted, they often have to be
17:50:50
stylewarning
mokulus: there are lots of articles written in the 90s-00s, and an ethos more generally, that lisp is this maximal state of enlightenment and everybody else who doesn’t use lisp must be an idiot or lowlife
17:51:55
stylewarning
mokulus: explaining why some people thought that (they *did* think that for a variety of reasons) is another topic, but that thinking has poisoned the well for many newcomers
17:53:33
stylewarning
phoe: it’s really truly a draft with lots of work to do http://watrophy.com/files/language.html
17:54:47
philweb
and if you go back to the 80's, lisp/smalltalk were positively magical vs the competition. the problem was the compute/memory requirements greatly exceeded what most of us had available (even working in most businesses)
17:54:58
stylewarning
Whenever it’s done it probably will be published as an ordinary blog posts not some kooky pdf
17:57:54
stylewarning
mokulus: scheme is really more of an idea and less of a language. There *is* a scheme standard, but it’s so barebones that every implementation of scheme is mutually incompatible
17:58:59
stylewarning
mokulus: scheme systems are super opinionated about things that matter when writing big programs: how modules work, how macros work, how you make a program efficient, etc. and everybody decides these things differently
17:59:32
stylewarning
mokulus: so at the end you don’t really have a thriving scheme ecosystem, you more have a handful of “self-sufficient” scheme tribes and dialects
18:00:14
stylewarning
Common Lisp has one and only one standard, and everybody agrees on it, and the standard is large enough to build useful applications, from tiny utilities to multi-million dollar pieces of enterprise software
18:02:29
stylewarning
(There is a subset of Common Lisp and the subset of Scheme that provide the same functionality, and arguably Scheme is much more elegant and prettier. But there’s also just a million things Scheme can’t do at all.)
18:05:05
stylewarning
Maybe a bit of a poor comparison: scheme is like a nice, razor sharp, clean chef’s knife with no patina; Common Lisp is more like a multitool with some scratches, that happens to include a reasonably sharp knife
18:05:26
aeth
In particular, the problem with portable Scheme was the lack of a portable library system. It's still there with popular Schemes, of course, but now quite a few support R7RS libraries.
18:05:47
aeth
Even ASDF systems among CLs was a hard problem, leading to UIOP. With Scheme it's harder.
18:07:44
aeth
As for capabilities, Scheme (well, *a* Scheme) should be able to do everything that Common Lisp does pretty soon.
18:13:45
contrapunctus
Hence the quotes around 'pretty soon', because it rather sounded like the project is some time away from production ready 🙂
18:17:14
aeth
I won't make it 1.0 before R7RS-large because any R7RS-large SRFIs being withdrawn and replaced (one or two already afaik) will break the public API... and that has been in progress since 2010. So if 1.0 is production ready, then it won't be for a long time, but that's not up to me.
18:19:20
VincentVega
Hi all! If I make class B inheriting from A, is there a way to easily initialize a A's slot with some different initial value or do I have to write initialize after for B and setf the value there?
18:23:40
VincentVega
Xach: I am trying (defclass b (a) () (:default-initargs . (var 2))) but it gives me invalid initialization argument error...
18:35:42
fwoaroof[m]
VincentVega: if you go the :initform route, make sure THE-SLOT is a symbol in the right package
18:57:08
contrapunctus
Ever since I started writing my first CL program I've been keeping a list of projects I want to improve the documentation for.
19:15:41
fwoaroof[m]
contrapunctus: it's an unpopular opinion, but I prefer to read code every time :)
19:16:33
fwoaroof[m]
High-level documentation is occasionally useful, but I'd usually rather see sample code
19:17:57
fwoaroof[m]
(even when there's documentation: unless you have some way to automatically make sure your documentation is correct, I find that most documentation lies about 6 months after it was written)
19:18:31
jmercouris
the only documentation I give the benefit of the doubt to is docstrings, and mostly only in our codebase
19:20:49
fwoaroof[m]
Yeah, I've been trying to figure out a nice way to specify docstrings in an executable format that can be stringified to something useful
19:21:10
fwoaroof[m]
doctests for sample invocations are one way to go, but I'd prefer to avoid parsing code out of docstrings
19:25:12
jmercouris
source for the function is embedded within a object that represents the documentation
19:31:37
contrapunctus
fwoaroof[m]: maybe it's because I'm not a professional programmer, but if I come back to my own code a few months later, on a program as small as 2k SLOC, I've often forgotten why certain design decisions were taken, or how a certain functionality works (which is why I write explanation docs), or that I've already written the function I'm writing (...reference docs). Many programs have reference docs b
19:31:37
contrapunctus
ut no how-tos, which is a total pain when you just want to get task X done _now._ (...so I write how-to docs).
19:31:43
fwoaroof[m]
I'd like a more structured way to express docstrings: something like #.(stringify '(:function (FOO ARG1 ARG2)) :returns ... :params ...))
19:33:59
contrapunctus
I also find reference docs invaluable in helping me improve API design (names, signatures, return values...)
19:35:08
pve
fwoaroof[m]: could you programmatically append stuff like function signature to the docstrings?
19:35:41
fwoaroof[m]
If you shadowed DEFUN, you could make the docstring portion much more structured
19:36:45
jmercouris
I don't shadow defun, instaed introduce a new constract that emits a defun and a corresponding object relating to its structure
19:36:58
pve
or a separate "signature" macro could both declaim ftype and add something to the docstring
21:47:08
drmeister
Hey folks. Over in #clasp we are developing a new Common Lisp implementation called 'clasp' and an extended version for computational chemistry called 'cando'.
21:48:08
drmeister
We are also developing a web based user interface based on common-lisp-jupyter. Tarn Burton, the developer of common-lisp-jupyter has been adding autocompletion of symbols, auto-indenting, and contextual help.
21:48:09
drmeister
https://www.dropbox.com/s/zwpbuq5qewz3m62/Screen%20Recording%202020-08-10%20at%205.39.20%20PM.mov?dl=0
21:50:51
drmeister
The jupyterlab kernel is getting me really excited - with the autoindenting (put the cursor on a parenthesis and hit tab) you can actually start to write code in the thing.
21:54:47
bjorkintosh
drmeister, is there a 101 intro to computational chemistry around? I know zero about the topic.
22:03:56
fwoaroof[m]
drmeister: cool, I've tried to build clasp locally several times and always get build errors
22:06:27
drmeister
New news - we have clasp working with the Memory Pool System copying garbage collector.
22:08:16
drmeister
bjorkintosh: It's a really big subject. https://www.acs.org/content/acs/en/careers/college-to-career/chemistry-careers/computational-chemistry.html
22:08:40
drmeister
Using computers to simulate the stuff that we are made out of. What could be more noble and fundamental than that?
22:10:10
drmeister
fwoaroof[m]: https://github.com/clasp-developers/clasp/wiki/Road-to-clasp-with-lvm@9
22:10:34
bjorkintosh
However, computational chemistry was not generally thought of as its own distinct field of study until 1998, when Walter Kohn and John Pople won the Chemistry Nobel for their work on density functional theory and computational methods in quantum chemistry.
22:12:47
drmeister
Because there is a lot of C++, C and Fortran code out there that you want to be able to work with.
22:15:54
drmeister
There are challenges as well. Many in my field have invested heavily in Python for scripting.
22:17:46
drmeister
So we are building an entire software stack with a very small team. We are doing everything from low level compiler optimizations to web-based graphical user interfaces.
22:18:46
drmeister
And we are developing applications within it. There are several demos in our docker image: thirdlaw/cando
22:24:55
fwoaroof[m]
drmeister: I've experimented with the opposite approach: using https://github.com/froggey/Iota to compile LLVM bitcode to Lisp
22:26:15
drmeister
I dunno about performant - the devil is in the details and there are a lot of details in a full Common Lisp implementation.
22:26:36
drmeister
But because we use the LLVM C++ API we can keep up with LLVM changes better than anyone.
22:28:13
drmeister
Because the code breaks when they (llvm developers) make changes and they make a lot of changes - and then it behoves me to update our code to keep up to date. I've kept with them from version 3.6 to 9 and I'm anxiously waiting for new changes coming in llvm12 (cross-fingers) that will make it easier to support Common Lisp.
22:30:58
drmeister
It's still very much a C/C++ oriented backend. But new changes that are coming will enable reloading of code in a way that will make it better for a more dynamic language like Common Lisp.
23:39:09
dim
drmeister: do you have a time frame in mind, or a target version number I could check, for clasp image save/load feature? I mean I could then maybe try and compile pgloader with clasp and see if your new GC beats the SBCL one...
23:40:08
dim
(we keep having issues with SBCL GC where we exhaust the heap with pgloader, and I don't know if pgloader is putting too much pressure because of bad code or just because of what we do: data processing) (also Clozure has no trouble with pgloader, as a data point)