freenode/#lisp - IRC Chatlog
Search
19:16:38
kristof
in my DIY understanding of implementing lisp I continually run into things that make me go "oof, how do I even make that fast?"
19:18:30
kristof
reader functions generated by a defstruct form are guaranteed to work correctly on any struct that includes its parent. in a statically typed language this is a simple matter because the offsets are the same
19:19:21
kristof
however... typechecking is now this ugly overhead on struct access when the type is unknown.
19:20:49
kristof
a simple eq check on the part of the data structure that holds the type is insufficient because I need to check ancestors now, too.
19:22:02
kristof
So I'm thinking I... first check if the type is what I expected. And if it isn't, I check the type object's ancestor. And I keep following that chain until I hit T. Right?
19:22:37
kristof
yeah, that's not the slow part, it's the typecheck when I don't have type information through inference or declare
19:22:48
kristof
but I guess the old advice remains the same. If you want it to be fast, declare declare declare.
19:28:14
bike
yeah, typep with a class basically means checking the class precedence list of the class of the object.
19:41:02
pfdietz
Ancestry queries in trees can be done with two comparisons (compare pre and post order traversal numbers).
20:10:24
anamorphic
API design question: I have a function (origin foo) => x, y (i.e two values) and I'm writing a corresponding (defun (setf origin) (new-value foo) ..) Would it be a better design if new-value was an array of two numbers, or would it be better if it were a list?
20:12:50
anamorphic
or a cons, or a (defstruct point (x y) ...) I guess a struct would make the get and set congruent
20:15:52
heisig
anamorphic: Unless your API is used from the innermost loop of an HPC application, you should use generic functions and (defclass origin () ...).
20:17:55
heisig
CLOS is surprisingly fast and makes your code much more maintainable in the long run.
20:34:41
sjl_
For the record: you can define a setf function that can set multiple things at once without an extra datastructure: (setf (origin foo) (values 1 2))
20:35:39
sjl_
But if you want to represent something with a data structure, then yeah a class is generally a good choice. Only use a struct if you've benchmarked and it's a bottleneck.
20:40:20
pjb
macros and special operators may do something else than mapping input to outputs. It's not "operator" in the mathematical sense.
20:41:08
anamorphic
sjl_, so something like (defun (setf origin) (new-values foo) (multiple-value-bind (x y) new-values ...)?
20:46:46
theseb
if anyone has any experience with large lisp dev teams......i'm curious how they maintain *readability* if the gurus start using lots of macros
20:47:45
sjl_
The docstrings for my hairier macros are often as long or longer than the macros themselves
20:48:33
White_Flame
and they don't even have to be separate .asd files, just collected and documented together
20:48:43
pjb
theseb: readability comes from the fact that all operators have nice names, such as WITH-OPEN-FILE or CHAR-CODE, and that the name of the opertor is the first element of each sexp = symbolic expression = list.
20:49:55
pjb
theseb: everything in C is hard, even obfuscation. This is why there is a C obfuscation contest. But there's no lisp obfuscation contest, because it's too easy to obfuscate lisp code.
20:50:48
theseb
pjb: seems to me ....a lisp dev team couldn't risk hiring average people....for what you said
20:51:07
White_Flame
using Lisp should be exercising your skills of abstraction, because anything can be done at the source code level. Thus, it's reasoanble to assume that Lispers will experience good & bad abstraction consequences and git gud at it
21:03:18
pjb
For example, in the expendables, everybody in the team is old and muscular. If there was a baby, you could make N old muscular men and a coffin, but not the expendables.
21:03:25
theseb
pjb: hmm..not sure how we could control the more clever impulses of the 3 comma programmer
21:05:09
theseb
pjb: The minute a team lead says..."OK we are going to limit what you are allowed to do for readability".....then they are moving towards Python
21:07:10
pjb
What can be said against 3-, is that it shows a lack of abstraction. The 3-, programmer has more capabilities, to be able to understand, write and read 3-, expressions. This allows him to use them, instead of introducing abstractions.
21:07:50
theseb
pjb: it is sort of like a reverse Greenspun's rule..."Every large enough lisp dev team contains a half baked spec of a Pythonic language"
21:08:48
pjb
I don't think. I feel that lisp allows you to write more complex software using fewer brain cells.
21:09:35
pjb
You don't need to remember a lot, since the syntax is simplier and clearer. And you don't need to understand a lot, because of the abstractions used in lisp programs. 3-, goes against that.
21:10:51
pjb
LdBeth: Your question is whether ecl is ported to avr. Again, I don't know, but if not, it should be easy to define avr as a target of ecl, AFAIK.
21:15:11
anamorphic
You might be interested in https://ferret-lang.org/ though. I was just reading about it. It supports AVR boards
21:25:39
jasom
theseb: "...then they are moving towards Python" this is absolutely not true. Readability is important and good abstractions are a net-gain in readability.
21:26:45
jasom
theseb: A common lisp style suggestion is "Don't use a macro when a function will do" which doesn't bring lisp even a tiny bit towards python, but is a net gain for maintainability.
21:27:37
theseb
jasom: i heard another suggestion which was...do as much of the macro in a normal function as possible..then just make a macro wrapper for it
21:28:19
jasom
theseb: I've heard that one; probably not as universal as the one I said. In any event, you can place limits on what programmers can do without hamstringing the language
21:29:26
jasom
theseb: in fact you could take your theoretical "pythonized lisp rules" and add "... except when necessary" to the end of each rule and already have something both restrictive, but more powerful than python.
21:29:38
jasom
(note this is a thought experiment, I think pythonizing lisp is not a good starting point).
21:44:22
jmercouris
how to loop through element in like (loop for element in list do ...) and have index of element within do part?
21:44:34
jmercouris
I seem to remember needing to have two clauses, but I can't remember how it should look
21:47:58
anamorphic
jkordani: you can do it this way too: (loop for i from 0 for elem in list do ...)
21:52:34
jmercouris
I wish I just knew it better, but it seems like there is so much to learn about it
22:13:05
PuercoPop
loke`: oi, just found stumpwm-dbus, can you share your setup config? Should I look at anything in particular beyond the formatter?
22:14:37
aeth
I thought it was just loop with s-expressions, but it's not, so it has an unnecessary learning curve and is unnecessarily complicated.
22:15:03
aeth
It also apparently only works with iterate:foo symbols, which doesn't really work well with the new style of not using :use for arbitrary packages. It should work on keywords.
22:16:48
aeth
i.e. (loop :for x :in y :collect (1+ x)) would just become (do-loop (:for x :in y) (:collect (1+ x))) and it would be a strict superset of loop so you could easily port loop clauses by adding parentheses.
22:21:05
aeth
The downside (other than having to, in effect, implement loop or port an implementation of loop) would be that it might not be sufficiently s-expressioned (s-expressed?). e.g. (:for-in x y) is Lispier than (:for x :in y)
22:22:24
aeth
(Of course, if it's a superset of loop, (:for x :in y) could be transformed to the preferred (:for-in x y))
22:24:20
aeth
White_Flame: If implemented with destructuring-bind that permits (:for x :then (* 3 x) := 1 :of-type fixnum)
22:24:29
White_Flame
maybe LOOP requires the ordering, but nothing semantically in that list of options does
22:24:55
aeth
White_Flame: I use keywords to implement a loop-like sum macro (for integer summation).
22:27:48
aeth
White_Flame: I would keep the order for LOOP's sections, and might even make them explicit with ()s like (do-loop ((:for x :in y) (:for a :in b)) ...)
22:28:17
aeth
The advantage is that that makes the sections explicit, the disadvantage is that that makes it harder to port existing LOOPs
22:56:28
jcowan
Today I read a claim that ACL2 is the most successful CL application ever; anybody have comments on that?
22:57:57
aeth
Maxima is used by SageMath, which is very popular. https://en.wikipedia.org/wiki/SageMath
22:58:40
aeth
I think Maxima is the only Common Lisp application in Fedora, and it might be a similar situation with other distros.
23:06:02
luis
How about Crash Bandicoot and its 50 million copies? (Not all versions used Lisp though.)
23:28:14
jiby
I've changed my exports (removed one, added other instead) in a trivial pkg and the removed exported symbol is "missing" all the time
23:28:51
jiby
I get that exported symbols would be very stable over time (who's silly enough to change their interface!? =p)
23:35:00
jiby
I'll be damned, neither worked to clear my exported symbol. Loading it again shows the same thing: caught WARNING: ; CL-YOUR-PKG also exports the following symbols: ; (CL-YOUR-PKG:MAIN)
23:35:03
jasom
jcowan: it's probably the only current day CL application for which it is the "one to beat"
23:37:12
jasom
jiby: (delete-package 'cl-your-pkg) (asdf:load-system :force t "my system that defines cl-your-pkg")
23:37:29
jasom
jiby: (delete-package 'cl-your-pkg) (asdf:load-system "my system that defines cl-your-pkg" :force t)
23:38:56
jiby
wow, hardcore. Seems to have cleared the exported symbol! thanks guys! Am I correct in assuming there is a big assumption of "thou shall not remove a symbol from your export" wrt. compatibility?
23:42:47
PuercoPop
loke`: For some reason overriding the stumpwm-dbus:popup-timeout doesn't appear to affect the durationg the timeout is displayed.
23:43:33
jasom
jiby: I don't think so (there is unexport, for example). However, static analysis tools are confused by exported symbols not in the defpackage, which is probably why SBCL warns.
23:44:30
jiby
fair, the warning is early on, and turns into a big fat compile error down the line. it's starting to make sense
23:44:38
jasom
ah "If the new definition is at variance with the current state of that package, the consequences are undefined"
23:45:32
jasom
so changing exports and imports are find, as long as you don't re-evaluate the defpackage form.
23:46:14
jasom
right, if you delete the package, then there is no existing package, and that line doesn't apply
23:52:16
PuercoPop
I'm guessing they don't due to the behaviour I'm observing in stumpwm-dbus but not sure
23:53:03
jasom
function lookups are non-thread-local, but sbcl makes assumptions about when they will be redefined. The same might be true for methods.
23:55:58
jasom
I don't think that PCL had any thread-specific code, but sbcl has divirged quite a bit from it now.
0:00:12
jasom
a simple test caused the method to propagate, but I wasn't running with optimization levels dialed up
0:01:11
jasom
and with optimizations high on the thread function (but not the defmethod) it also propagated.
0:02:09
jasom
My test used an eql specifier for the method "foo" and looked like this: (sb-thread:make-thread (lambda () (declare (optimize (speed 3))) (loop (foo 'foo) (sleep 1))))
0:04:23
jasom
Of course I didn't try e.g. (defmethod ((foo child-class)) ...) then spawn thread and (defmethod ((foo base-clase)) ...) which might be different
1:37:04
WhoTookMyName
Hello. How can I get a bareword like not to expand to something like (not x)? Can I do a macro for that?
1:40:39
WhoTookMyName
So something that expands (defun my-not (x) not) into (defun my-not (x) (not x)) or the like.
1:41:10
WhoTookMyName
The only way I've been able to think of doing it is maybe modifying the readtable in some way.
1:42:03
no-defun-allowed
(setf (fdefinition 'my-not) (fdefinition 'not)) would be how i'd usually handle it
1:47:10
WhoTookMyName
The basic thing I'm working for is to have a "toggle" variable x that switches back and forth when I write x in a function definition or somewhere. This way (toggle toggle) gets shrunk to just toggle, making it less redundant.
1:57:25
no-defun-allowed
threads work on sbcl on macos, linux (x86, not arm) and windows from testing
1:57:54
z3t0
okay, from the manual I can see that threads need to be explicitly enabled when being built, other than on linux
1:59:29
no-defun-allowed
aeth: another one about gitlab CI: can you somehow get the path of the repository from the environment? i mirrored a repo on c-l.net with a different username and it broke
1:59:46
no-defun-allowed
looks stupid to have a "fixed CI" commit where the CI failed: https://gitlab.common-lisp.net/theemacsshibe/cl-decentralise/issues/1
2:33:40
elderK
:P It's really like 1533 here. But I consider whenever I wake, to be logical morning :P
2:34:56
jcowan
The "IRC time zone" is that in which when you join it's morning and when you leave it's evening.
2:39:32
no-defun-allowed
ok it works aeth, see https://gitlab.common-lisp.net/theemacsshibe/cl-decentralise/blob/master/.gitlab-ci.yml#L8
2:52:40
loke`
PuercoPop: I checked my config, and I'm not actually using that fetaure so it may be that it doesn't actually work.
2:54:00
loke`
PuercoPop: Here is my confiog, if you're intersted: https://gist.github.com/lokedhs/f87f4564b56628566c8d7ada23fd1d9e
2:57:02
z3t0
I have rebuilt from the latest source with --fancy but I still get an error saying make-thread is undefined
3:16:58
elderK
What do you do when you have say, a reasonably complicated form for initializing optionals, etc.
3:17:33
elderK
I've seen their style guide - it didn't contain much in the way of formatting information. Although, I'll look again, just in case I missed something.
3:19:42
elderK
Which is only so useful to me. Surely, somewhere, the formatting rules of SLIME must be codified somewhere?
3:35:19
PuercoPop
Thanks for your config, and stumpwm-dbus seems great, do you want to limit the scope to notification or does stuff like battery reporting still in scope?
3:37:13
loke`
I haven't worked on it for quite some time, because frankly it works pretty well for me. :-)
3:38:04
loke`
I had intended to implement support for interactive notifications, but I was waiting for the Stumpwm-native UI. As you may have noticed, I'm using McCLIM right now.
4:20:58
jcowan
Someone gave me a little script that runs Emacs in batch mode to format Lisp code on stdin and writes it to stdout.
5:07:25
aeth
I wonder if there's a way to handle out-of-Quicklisp dependencies without installing git
5:27:51
gendl
elderK: Um, I'm no expert, but from what I know (which is little), you would need a custom hacked macro for that.
5:38:13
cgay
with-slots is defined in terms of slot-value, which seems pretty clearly about defclass.
5:43:23
aeth
gendl: You should always use with-accessors, even with standard-objects (defined via defclass)
5:44:21
aeth
gendl: What I sometimes do is this idiom in a defclass slot definition: :reader foo :accessor %foo
5:44:41
aeth
Then I can with-accessors on %foo internally (it's weird having a writer that's not a reader with with-accessors) but only export foo
5:46:27
aeth
That solves slot-value for internal writing on something that shouldn't otherwise be written.
6:10:58
no-defun-allowed
i would not suggest buying 27 machines for 27 combos, maybe do one OS per box and run VMs on those
6:10:59
gendl
European commission. We got sucked into a euro research project. ("we" being Genworks BV, a Dutch subsidiary we formed to avoid tax issues with foreign bank account for U.S. citizen).
6:11:50
gendl
but the Dutch partners of this EU research project ("Agile"), decided to switch to our Python-based competitor near the beginning of the project
6:12:33
no-defun-allowed
if macOS is in the testing system, the mac will easily cost more than the other two boxes combined so glhf
6:12:39
gendl
so we ended up (with almost no feedback) doing essentially what we wanted to do, for this project.
6:35:01
gendl
No other major wine region placed their top estates in 5, simple, easy to understand categories with those results being officially certified by the French Government.
7:12:20
elderK
Hey guys, I'm trying some IO Stuff. Parsing something form a string. I was wondering if it's possible to like, include a literal newline in a string, such that read-line (when using with-input-from-string) will consider them individual lines