freenode/#lisp - IRC Chatlog
Search
7:28:09
beach
asarch: I would probably use BIT and test for 0/1. Otherwise, you get a full word for each value.
7:32:37
beach
Like I said, if you want NIL, you get a full word for each element. You can do that if you want, but the element type would then be T.
7:34:37
beach
If your choices are 0 or 1, I don't see what the problem is, and I don't see why you would choose NIL.
7:35:07
beach
If you want NIL in there, then since NIL is a symbol, you will have an array of element type T.
7:35:32
beach
It is very unlikely that your Common Lisp implementation has a Boolean element type for arrays.
7:43:06
asarch
One last stupid question: how would I get a full-created array with the 35 elements with nil so I could randomly (setf (elt my-array some-random-index) t)?
7:43:44
asarch
I got: "Invalid index 3 for (VECTOR T 35) with fill-pointer 0, should be a non-negative integer below 0."
7:46:08
asarch
I do (setf (elt my-array 3) t) and I get: Invalid index 3 for (VECTOR T 35) with fill-pointer 0, should be a non-negative integer below 0.
7:47:08
asarch
I use: (my-array (make-array the-size :adjustable t :initial-element nil :element-type 'T :fill-pointer 0))
7:48:45
beach
asarch: ELT obeys the fill pointer, so if you set it to 0, that means your array has 0 elements in it.
7:49:24
asarch
And mostly because I get: #(NIL NIL T T NIL T NIL NIL NIL NIL NIL NIL ...) is not an array with a fill pointer.
7:50:22
asarch
So, how would create an array with 35 initial element set it to nil with the possibility that the array could increase its size dynamically?
7:51:33
beach
You could use AREF which doesn't take the fill pointer into account, or you could not have a fill pointer.
7:53:56
beach
... or you can set the fill pointer to T when you create the array. Then it will be the same as the size of the array initially.
7:56:12
asarch
Array: #(NIL NIL T T NIL T NIL NIL NIL NIL NIL NIL NIL T NIL NIL T NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL)
8:45:07
ralt
anyone knows a library that can be used to send/receive file descriptors over unix sockets? Using ancillary data. I'm fine if it's sbcl specific.
11:56:10
dim
beach: I'm trying to find your protocol document pdf where you explain how to implement protocols first, you have authored such a doc right?
11:57:37
beach
I have a chapter of a book that explains what a protocol is. But nothing else I think.
12:02:02
dim
context: a friend of mine is trying to figure out how CL would approach the async situation that Python finds itself into nowadays, and I'm like, you know, we don't need any language-level decision making, any lib could do that
12:02:31
dim
you could easily have an async protocol or even just a protocol implementation that is async
12:03:29
beach
I am afraid I don't know what the "async situation that Python finds itself into" is.
12:05:36
jackdaniel
dim: do you mean a situation, where you have a protocol i.e for a mailbox, and that protocol could have a thread-safe implementation and a simpler implementation that works only in a single thread?
12:07:26
dim
beach: I'm still trying to figure out what my friend means here, it seems to be both a syntax issue and a semantics issue, where you have to use what the core developers of the language have designed
12:08:14
dim
in that case, methods have to be declared async and then return with the await keyword in their source, and the caller then must use another keyword to plug into the event loop of async stuff, if I understand correctly
12:09:00
dim
the most comparable thing to me would be providing the same protocol with both a sync and an async implementation and the caller would have to pick one at call time
12:09:55
dim
but I think my friend is curious more about the language itself somehow, well, let's be honest, I'm lost here ;-)
12:44:00
ralt
dim: either way, you might be interested in https://orthecreedence.github.io/cl-async/2013/03/26/green-threads-and-async-programming.html
12:47:26
jmercouris
phoe: how did you connect with GDB to get this output on this issue: https://github.com/commonqt/commonqt/issues/34 ?
13:01:14
phoe
jmercouris: I don't remember anymore, but I think attaching a debugger is standard stuff
13:02:20
jmercouris
I know how to attach the debugger, I didn't think there would be any other information than some memory addresses though
13:16:51
VincentVega
Is there a library that would do permutations directly on lists out of the box? E.g. (1 2 3) with length 2 -> ((1 2) (2 1) (1 3) (3 1) etc). I found cl-permutation, but it just permutes numbers, and I don't want to convert a list into a vector and all that. And it also doesn't seem to support length, unless its larger than the permutation size. I
13:16:52
VincentVega
can see some other math libraries on cliki, but the immediately relevant ones I could identify are not on quicklisp, but maybe someone happens to know one that I am not seeing?
13:19:14
jackdaniel
VincentVega: how about (alexandria:map-permutations #'print (list 1 2 3) :length 2 :copy nil) ;?
13:37:55
jackdaniel
I don't know whether it keeps all permutations in the memory, but in principle it should not to avoid blowing the heap when working on somewhat big sequences
13:45:35
flip214
you can just have (lambda (x) (push x my-list)) instead of #'print to accumulate the results
14:06:08
jdz
VincentVega: I'd also suggest looking into screamer, where working with permutations would not require consing up all the results first.
14:16:58
aeth
I don't know about the particulars of that library or the problem, but with numbers in general, if you can phrase the problem as MAP-INTO on an simple-array (whose elements' type is known) then that's usually an easy performance gain, which you might have to consider if it's large.
14:22:19
aeth
Iirc (map-into a the-same-lambda a) assuming you don't need the original around anymore. Not as elegant as pure functions and in theory a compiler could do this (in practice, no CL one will), of course.
14:23:02
aeth
Don't do it on '(1 3) though because that's literal. You'd need to use (list 1 3) if you're still using a list.
14:24:26
VincentVega
jdz: I did stumble into that library once, maybe I need to learn some prolog first to understand what kind of problems it would be well suited for, because it looks pretty esoteric to me at this point (in a good way). Do you use it often?
14:25:35
aeth
phoe: yes, but you'd probably want something more like (map '(simple-array (unsigned-byte 32) (*)) ...) or whatever you think can contain your problem. (Which is why float types are great, because they definitely will stay that float type unless you mix them with other types of floats, or explicitly coerce them, or accidentally make a complex)
14:26:52
aeth
Anyway, these are very, very small changes that can make huge performance gains, but generally only with numbers (and maybe characters)
14:34:05
dim
ralt: I like lparallel and I'm not sure if I would need more than that for my async needs
14:35:11
ralt
dim: an example I like is the actor model that Erlang uses: you want to have a queue and a thread per object, and if you have millions of objects, you need millions of threads. It is not feasible with OS threads, but perfectly fine with green threads.
14:39:48
jdz
VincentVega: I've played around with it a bit, and used it to solve a problem once. But I remember working with permutations (i.e., non-determinism) was really convenient, straight forward and with no performance penalties in Screamer.
14:42:58
dim
usually you have a `make install` target or something similar, and install all your scripts in either /usr/local/bin or maybe ~/bin or somewhere else, and yes that place then needs to be listed in PATH
14:44:42
amerlyq
can someone explain or give me link/chapter where described how Lisp "live coding" works under the hood? I used swank in emacs and everything worked intuitively, but when I tried to reproduce same _workflow_ with ipython/jupyter -- it was barely "live coding" requiring to reload everything recursively (due to multilevel assignments through modules, instances, methods, etc). And I can't grasp the
14:46:09
beach
What is it that you are having difficulties with? I mean, one thread will be executing the program, and another thread runs the REPL.
14:49:28
dim
I don't know, I'm not used to thinking at that abstraction level, and lparallel has a notion of a kernel with a number of workers and only some of them might be allowed active at anytime, so it might implement what you're talking about already
14:52:55
jackdaniel
probably that's the reason why many things doesn't work as you would expect in python when you try incorporate live coding
14:58:53
amerlyq
beach, jackdaniel: basically I tried "hy" which is lisp syntax for python, but... it didn't worked like lisp :) CL design is to have global symbol table and to resolve symbols before calling, moreover to store values of these symbols on stack as per-frame env
15:00:04
jackdaniel
it is a little more complex than having a global table, but sure, that may be a nice metaphore
15:01:13
amerlyq
beach: but it's enough to conclude that python has too much isolation between modules/instances etc. and you can't easily replace e.g. method in class without monkey-patching or reloading whole module and recreating all instances
15:03:11
amerlyq
so, the question is -- how CLOS in CL had overcome this assignment limitation? Are class methods still contained in "global table" or only on stack of instance data?
15:04:13
jackdaniel
amerlyq: this is a must-read for you (IMO): https://www.xach.com/naggum/articles/3243735416407529@naggum.no.html
15:06:39
beach
amerlyq: When you add a method to a generic function, its discriminating function is recomputed so that the next time the generic function is called, the new method is taken into account.
15:15:22
amerlyq
jackdaniel: nice read, thanks. As I understood from it -- specific methods are added to local table of generic, not to global one. So to reload method, you must reload whole generic.
15:15:37
amerlyq
> redefine a generic function with `defgeneric´, a fact that you should note right now before it comes back to bite you if you think you can load a file of updated `defmethod´ forms and expect it to run
15:15:46
jackdaniel
amerlyq: when you define a new method, the generic function is updated, as beach said above
15:16:10
Xach
ACTION fondly remembers the dining lispers problem at Mary Chung in Cambridge - having a fun conversation with kmp and others about the clhs
15:16:40
beach
amerlyq: You can forget about "loading" and "reloading" it is just a matter of evaluating forms.
15:21:35
beach
amerlyq: But you could definitely load a file containing DEFMETHOD forms. The next time the generic function is called, those methods will be taken into account.
15:22:20
amerlyq
sorry on that, it's a hard to escape matter of habit -- when talking with other langs devs, they are more familiar with concepts of "hot reloading" and "live coding". Basically I used "reload" to focus only on this aspect of "form evaluation".
15:22:42
amerlyq
beach: but "will be taken into account" contradicts my quote above from jackdaniel link
15:22:43
jackdaniel
there is a fancy exception: methods defined as (:method …) option to defgeneric are removed before the function is redefined (and if still present -added once again)
15:24:18
dim
I think image based development as in CL is also sometimes referred to as “incremental compilation” (rather than reload)
15:24:21
jackdaniel
amerlyq: that quote you've mentioned talks about things you can use with a default generic function
15:24:39
jackdaniel
(i.e when you forget to write a defgeneric form), in other words it speaks about something else
15:25:11
jackdaniel
namely - always define a function with defgeneric, do not depend on defmethod defining a function for you
15:31:54
amerlyq
Hm, in this case "jet-live" approach for incremental compiling in C++ is more similar to Lisp, than any python approaches. Jet-live has global table of symbols, which prolog it rewrites by tramplines to newly added code, and actually broken OO becomes a generic-like bunch of differently named functions. The only problem is related to not preserving multiple environments on stacks and problem that
15:33:25
amerlyq
by the way... are there any other non-lisp languages designed for interactivity from the start? I seem can not find anything outside of research papers
15:37:12
aeth
to be fair, Common Lisp already took inspiration from the relevant parts of Smalltalk :-p
15:38:11
aeth
I suspect that Common Lisp is a bit more successful than Smalltalk because Smalltalk is more deeply integrated with the editor, so it needs a good IDE, not just a good implementation.
15:38:13
alandipert
java/jvm were designed from the start to load code at runtime, later this functionality allowed jvm to host various dynamic langs, so support seems slight at worst imo
15:38:53
amerlyq
Gnuxie[m]: from scientist standpoint -- yes, from engineer standpoint -- no. Basically you need tons of libs to strive now, because after 30 you don't have time to write them yourself anymore :) And without libs even kicking lang is as good as dead for me, as it will never cross the borderline of kitchen experiments.
15:41:11
phoe
alandipert: hm, yes, if we take Java classloaders and such into account - but that'a already #lispcafe material
15:43:19
jackdaniel
amerlyq: I think that you are oversimplifying; from the engineer standpoint abstraction-bloat and updating all libraries on weekly basis (I'm thinking about what I saw when npm and pip were part of the build process) is a disaster
15:46:45
jackdaniel
seeg1234: (defun append-suffix (path suffix) (make-pathname :name (concatenate 'string (pathname-name path) suffix) :defaults path))
15:51:41
amerlyq
jackdaniel: I'm not so sure. If you need some components, especially integration-like ones, you simply pick between maintaining stream of updates from others, maintaining frozen version, or maintaining constant development of your own. You simply convert the same your personal time into one of chosen complexities. And I don't see how to NOT convert your time at all.
15:52:46
jackdaniel
all that I'm saying is that what you describe is a work of a plumber, not an engineer
15:53:27
amerlyq
aeth: considering I felt like "Pharo demo show so much mouse clicks to get things done... lets try to write in vim", you may be right on that :)
15:55:32
dim
my understanding is that the comparing is not in the right dimension here, when using vim/emacs/editor you edit a file with characters that are going to be transformed into code later by some tooling or another, in Pharo you actually edit the code itself, live
15:55:57
amerlyq
jackdaniel: and what engineer isn't plumber? You still combine your abstractions to get model in the same way like you combine libs to get work done. Nothing changes beside type of dirt on your hands.
15:55:58
dim
and I believe Common Lisp with SLIME or equivalent sits in the middle of the two models
15:57:30
amerlyq
dim: you edit "code representation as text" in Pharo, not code itself :) So you still have explicit compilation transactions at checkpoints, despite being hidden. Nothing different from slime.
15:59:11
jackdaniel
I suppose that wasn't a question but rather a revelation, so I'll get back to my things
16:00:51
amerlyq
So, at the end of the day we still have only CL, Pharo, and maybe Forth for live coding. Seems like I cease my attempts to make CL from the python (but a pity).
16:09:14
dim
I would add Emacs Lisp and Clojure/Kawa and Racket and some other Scheme implementations to that list I believe, and Prolog and Erlang too, and most certainly quite a number of other things that I don't know exist yet ;-)
16:28:09
sjl
Is there a way to print a rational as a decimal with an arbitrary amount of precision in CL? Format's ~F converts the number to a float first, so if the rational requires more decimal places than double-float can handle it won't work.
16:28:35
sjl
(I ended up using https://wukix.com/lisp-decimals to do it for this one off-the-cuff calculation but was wondering if there's a built-in way)
16:37:05
beach
sjl: Can't you just multiply it by (expt 10 <number-of-decimals>), round it, and then insert a period before the decimal part?
16:38:04
sjl
I could probably cook up a function to do it... I was hoping there was something easily built-in that I was missing though
16:38:26
phoe
I don't think so; CL has no real support for fixed-point numbers, which is what you want to do here
16:39:14
beach
[sorry, bad joke. I have had to deal with another suggestion for a new standard lately]
16:41:27
alandipert
fiddlerwoaroof this "generalizer" paper/code you sent is really interesting, thanks for that. opens my eyes to the continuum of things before predicate dispatch and dependent types
16:43:50
beach
I just wasn't sure. I guess I confuse it with the kind of system where you do all the work inside the running system, even edit code and such.
16:46:55
waleee-cl
By that definition factor is leaning more to the interlisp / smalltalk & pharo-side
16:53:32
alandipert
in a couple days i will be giving an online presentation aimed at interesting Clojure programmers in CL, but i welcome any lispers here who are interested in the clojure perspective and/or helping me make my pitch :-) https://clojureverse.org/t/scicloj-public-meeting-common-lisp-for-the-curious-clojurian/7060
16:55:05
aeth
All you really need is variations of float-producing functions like SQRT with user-specified precision that result in rationals (and no, ISQRT doesn't count, even if it does technically result in an integer, which is a rational)
17:03:36
amerlyq
alandipert: so, is Clojure live coding is a thing in the same transparent way as CL/slime? If you don't mind amateurish question.
17:05:30
alandipert
amerlyq clojure prefers sticking with JVM limitations when they conflict with CL debug/repl affordances, so from the CL perspective it feels rather impoverished