freenode/#lisp - IRC Chatlog
Search
3:58:42
pillton
Anyway, I'll shut up because I don't really know and because I have to go to a meeting.
4:01:54
mfiano
Is anyone really familiar with the trivia library? I cannot seem to figure out how to compose the 'struct/class' and 'place' patterns, such that I can match a struct and define symbol macros for their slots in the process. Thanks.
4:09:30
beach
MichaelRaskin: I don't know how feasible your idea of hooking Clordane up to SBCL is, but you gave me a similar, but different, idea. I can create a Cleavir-based compiler for SBCL that propagates source information to executable code and that adds the interaction code required by Clordane. Again, it won't be as fast as native SBCL, but it will me much easier than to wait for a native SICL executable.
4:15:28
beach
MichaelRaskin: It would still take some time to create Clordane and this Cleavir-based SBCL compiler, of course. But such a thing would allow me to debug SICL code in a very comfortable environment without having to deal with the additional problems of a native SICL executable.
4:16:27
beach
MichaelRaskin: So I will probably move Clordane closer to the top of the list of projects to work on.
5:12:55
asarch
bar and baz both have the foo function. How could I shado baz::foo instead of bar::foo?
5:14:03
beach
asarch: It is a bad idea to :USE packages other than COMMON-LISP. Use explicit package prefixes instead.
5:14:39
beach
asarch: your code will be much clearer, because the person reading it will know from which package the symbols came.
5:15:08
beach
asarch: Plus, if you find yourself needing two ::, then you are doing something wrong.
5:15:54
beach
It means you are violating the public protocol of those packages, OR that you didn't design those packages correctly (in case you are the author).
5:17:47
MichaelRaskin
beach: I thought a bit, and as long as you accept limitations about not being able to see return value of top-level eval-when, the rest seems very feasible and not too much work.
5:17:56
beach
If a package P is not yours and you do a :USE P, you expose yourself to future modifications of P. If, in the future, the author of P decides to add new functions to the public protocol(s), then your code could break with a conflicting-symbols error even though you have not changed anything.
5:19:37
MichaelRaskin
Probably the eval-when problem can be solved with a few tons of annoying special-casing.
5:20:32
jack_rabbit
asarch, So double colon references symbols interned by a package. Single colon can only be used to reference symbols *exported* by the package.
5:21:16
jack_rabbit
asarch, So packages export symbols they intend to be used. A library will export functions it wants library users to call, constants, variables, etc.
5:21:53
jack_rabbit
asarch, internal variables, functions, etc. that it doesn't want a user to use, it doesn't export.
5:22:21
jack_rabbit
asarch, So when using a package, you should (almost always) only use the exported symbols (single colon)
5:23:10
jack_rabbit
asarch, That's why beach said you're either doing something wrong, or the package creator did something wrong, if you're using the double colon to use non-exported symbols.
5:25:53
jack_rabbit
Oh, minor note. Symbols that can be accessed with a single colon can *also* be accessed with a double colon. It's just best practice to use the single colon.
5:26:31
asarch
(defpackage :bar (:use :common-lisp) (:export :foo)), (defpackage :baz (:use :common-lisp) (:export :foo)) <- I don't want to use :foo from baz in :asarch
5:28:06
jack_rabbit
asarch, packages have access to other loaded packages, even without :use'ing them.
5:29:02
asarch
If I do: (defpackage :asarch (:use :common-lisp :bar :baz)), I would conflict the REPL at the time when I use (foo), right?
5:29:55
jack_rabbit
<jack_rabbit> asarch, packages have access to other loaded packages, even without :use'ing them.
5:30:29
jack_rabbit
asarch, It's not like java or python, etc. where you have to import packages to have access to them.
5:30:30
asarch
(defpackage :asarch (:use :common-lisp)) <- But any other functions in bar or in baz would not be accessible
5:36:07
jack_rabbit
asarch, When you :use a package, it just imports all that package's symbols into the target package, so they can be used as if they were part of the target package.
5:37:04
jack_rabbit
That's what beach advised against. Using explicit package prefixes makes the code clearer, since you can tell at the call site where functions, etc. reside.
5:39:46
jack_rabbit
It makes sense once you get used to it. It's just a little different than a lot of common systems.
7:32:25
verisimilitude
I wanted to make you aware of an article I've written that is related to yours:
7:33:12
verisimilitude
This is what I've been meaning to do since first reading your ``CL-CHARMS Crash Course''; it's a first draft, but I'll work on improving it later.
7:54:37
beach
jackdaniel: Unless you are in a very good mood, my advice is for you to ignore that link.
8:22:40
jackdaniel
verisimilitude: calling people idiots is not the best way of communicating your ideas
8:30:46
beach
In each iteration, you remove a CONS cell from the beginning of REMAINING, and you stick it first on the list RESULT.
8:37:39
beach
Er, when you are done, all the initial CONS cells are on RESULT (not REMAINING) in reverse order.
8:50:16
verisimilitude
I suppose xterm is just carrying on the UNIX way of making up stardards and violating real ones, anyway.
8:54:15
verisimilitude
It could be better, yes, but my main intent was showing how easy it is to write this functionality without using Ncurses.
8:55:49
verisimilitude
The code in ACUTE-TERMINAL-CONTROL is much better; I've updated it, but not yet published that update; the article is a ``crash course'' for that, in a way.
9:05:11
jmercouris
instead of just randomly splitting the window and ending up somewhere in the frame?
9:10:12
jackdaniel
verisimilitude: can I use it in my gnome-terminal? because if not, I'm definetely not your target audience
9:11:01
verisimilitude
I do extensive testing in gnome-terminal, actually, because I like its looks.
9:11:05
jackdaniel
and as I've said, examples weren't complete programs and I hardly understood 10% of it
9:11:35
verisimilitude
I'm only using standard ECMA-48 control functions, so most any terminal should work with it.
9:12:32
beach
verisimilitude: It is not just my opinion. It is also that of Peter Norvig and Kent Pitman. Can I assume you have read their "LUV slides" on Good Lisp Programming Style?
9:15:57
beach
jmercouris: When you need a different evaluation rule than a function provides, i.e, you don't want all the arguments to be evaluated.
9:18:00
beach
Sure, you can use a macro both in the expander code and in the expanded code. That's not a problem.
9:18:33
francogrex
Hi, I wonder if someone could help me understand why when I load this clsql asdf there is a recompilation every time (!) https://pastebin.com/Ad0aVkuC
9:19:17
francogrex
I understand that the first time use this is expected but every new time is weird
9:19:50
beach
verisimilitude: For instance, in (OR CURSOR (error ...)), you are violating one of the rules on page 13.
9:20:13
makomo
jmercouris: some macros are written just for the purpose of writing macros for example
9:22:10
francogrex
jmercouris: ok it seems the fasl files compiled by asdg are still were they are (cached)
9:22:16
jmercouris
here is my macro for reference: https://gist.github.com/15acdd2b6ef7f6f14e4c8741b748be7a
9:22:33
beach
verisimilitude: So when you said "That doesn't really tell me much at the present", you hadn't really looked at it yet?
9:24:22
makomo
jmercouris: using a function in this case would mean that you would still have to use a conditional within the caller
9:25:11
makomo
i think you misunderstood me, but if i correctly see what you're thinking, that's correct i guess
9:25:43
jmercouris
I'm saying that if "with-logged-in" is a function, the body of whatever you pass to it will get evaluated
9:26:57
makomo
but if this session check happens only a few times, factoring it out in a macro might be an overkill
9:28:09
makomo
what i was trying to say is that, without macros, you would be forced to do this conditional in the function that calls LOGGED-IN-P
9:28:34
makomo
or maybe you would have something like CHECK-LOGGED-IN that would somehow do a non-local transfer of control or something? idk
9:28:56
makomo
perhaps throw an error and catch it somewhere else, but then you're using errors for control flow and i don't know how good is that
9:29:14
makomo
maybe CL has different guidelines regarding that since the condition/signal system is more powerful
9:30:20
makomo
verisimilitude: yeah i suppose so, but i haven't seen any usages yet where it was used to guide "normal" control flow
9:35:54
beach
verisimilitude: Yes, I figured you would say that. But style issues are not about personal preference but about communication with other people. If you submit your code for others to read, it would be polite to respect such conventions rather than insisting on your own personal preference.
9:36:36
verisimilitude
Well, I like that Common Lisp is a language without kings and other such things.
9:45:48
verisimilitude
Well, it's just example code. I'd be interested in other critiques about it, though.
9:45:52
dim
I'm in the middle of rewriting a PR due to code style issues, and I don't like doing it, but I appreciate that the result is worth it
9:48:33
beach
verisimilitude: Style issues are distractions to the people reading your code. You can't expect people to ignore those issues and concentrate on something else, simply because the distraction is too great. It is sort of like asking someone to comment on the contents of a novel that is full of typos, typesetting problems, grammar mistakes, etc.
9:49:33
jmercouris
I often have to read massive, old codebases that include many different styles as they evolved
9:49:35
beach
Conventions are about avoiding distractions so that people can concentrate on the essence. Programmers who don't understand that have not understood the first rule of programming.
9:50:19
verisimilitude
My intention was to show how simple it is to write terminal manipulation programs without Ncurses.
9:52:07
verisimilitude
I don't quite like the CFFI, jmercouris; ideally, no Common Lisp program should be using a C program for anything.
9:52:43
jmercouris
personally I do not mind it, if it is correct code, and it works, it could be written in potato
9:52:46
verisimilitude
The loading mechanism is also, as I've found, fragile, and you can very easily be prevented from loading a program because it can't find some shared library somewhere.
9:53:43
verisimilitude
For something as benign as terminal manipulation, it's surprising Ncurses was ever used like this.
9:53:49
jackdaniel
interesting (for me) is the fact, that we can talk about two NIH variants (both popular)
9:55:22
verisimilitude
I prefer this way to the alternative; I wouldn't want Common Lisp to be like, say, Go.
9:58:58
jmercouris
but communities with 10x, 100x as many users have the same amount of web frameworks
10:01:05
verisimilitude
This is a good document so far, beach, sans that note about IF, WHEN, and OR I disagree with.
10:02:16
jmercouris
beach: not sure what you mean, I did isearch-backward and I didn't say number or "amount of stuff"
10:03:03
verisimilitude
I'm not always inclined to create a class or struct when I want a record; usually, it's more convenient to use a list and simply control all ways things are modified.
10:03:32
jackdaniel
they (frameworks) probably passed this strange point where numbers become amounts, we can't count them anymore ;-)
10:04:23
verisimilitude
I'm certainly not going to make types that are simply standard types with a documentation string attached.
10:05:19
beach
verisimilitude: Using a list is fine, as long as you wrap it in a consistent protocol. I suspect you wouldn't do that, though.
10:05:48
beach
verisimilitude: Then you would have more code than if you did it with a standard class.
10:06:19
verisimilitude
I'd rather use standard types if I can, then introduce my own types and then functions that only work on those types.
10:06:32
beach
... :accessor bla, vs (defun bla (thing) (car thing)) (defun (setf bla) (new-value thing) (setf (car bla) new-thing))
10:07:01
verisimilitude
One of my favorite type sysetms is APL's; you have arrays or single values of numbers or characters and that's it.
10:09:17
TMA
verisimilitude: try the type system of MUMPS, even simpler... you have string and associative array (each variable is both at once, and each variable value is both at once, although expression values are just strings)
10:10:06
jackdaniel
I like the binary type system, everything is either 1 or 0 ;-) that said I'll check on later \o
10:10:45
verisimilitude
The ``type system'' of a typical machine code is what enables its homoiconicity, so, yes, it's very nice.
10:15:03
xificurC
I have a function that is used from a script and is calling exit at the end. Invoking that in the slime REPL exits the session :)
10:16:26
xificurC
when writing bash scripts and calling a script from the repl the script is a forked process so it exits with an exit code and you're back in the shell
10:17:39
loke
verisimilitude: Bash is reasonably sensible. What aspects of it do you feel that is odd? (as opposed to its ancestors)
10:18:17
verisimilitude
Well, I can't rightly criticize Bash if I don't get to criticize sh and everything else.
10:18:45
TMA
loke: there is no string representation of an array (that is no "builtin" string representation) you can write your own, eg.: a="a" a("a")="a" a("a","a")="a"
10:19:59
verisimilitude
I mostly use sh for writing programs to launch my real programs. I'd hate more to do anything else in it.
10:30:14
verisimilitude
If you want efficiency, it's virtually guaranteed you're going to get a better expansion than LOOP; LOOP implementations are generally quite poor in that respect.
10:31:13
verisimilitude
What does SBCL's LOOP MACROEXPAND to, SB-LOOP::LOOP-BODY; that's very informative.
10:52:59
verisimilitude
Now, with regards to my article, I can recognize the obvious issues with DRAW-WINDOW-BORDER and how some of the other functions could be cleanly split into more parts, but I was aiming for one direct purpose for each function and doing otherwise would've distracted from the actual points being made, I think.
11:18:38
aeth
verisimilitude: I find that the often-neglected DO is a nice middle ground between LOOP and TAGBODY/PROG, especially for macros instead of direct use.
11:18:59
aeth
DO also tends to have a straightforward macroexpand-1, unlike LOOP, and you *can* put GO in it if you need to.
11:21:29
aeth
As for PROG, it's so rare to use it directly that emacs/slime doesn't even correctly format it iirc, unlike tagbody.
11:23:41
aeth
As for sh, imo it's only a good choice for < 20 lines or so, but it's pretty hard to beat for those < 20 lines.
11:28:05
aeth
I've always thought that the optimal length of a scripting language file is about 100 lines.
11:29:32
aeth
That's 5x longer than my intuition for sh. And it does seem to match my experience in trying to convert sh to a scripting language, even CL + UIOP.
11:31:14
dim
is there some docs online showing how to compile SBCL with say openssl already linked in the ELF binary (avoiding dlopen)?
11:32:25
aeth
Some people were experimenting with packaging libraries with binaries in #lispgames so they might have an answer if no one in here knows. (As for me, I never got to the binary part.)
11:47:34
dim
because it may dlopen a different ssl lib at build-time and at run-time, and then the lisp image contains symbols that are not found, and then I don't undertand anything other than it fails
11:53:57
beach
shka: It assumes a total ordering, so if neither (funcall less x y) nor (funcall less y x) is true, then it assumes x and y are equal.
11:55:00
jackdaniel
stability only ensures, that if a preceedes b, and neither is lessp then the other, then a will preceede b in the resulting sequence
12:00:28
beach
shka: Right. STABLE-SORT typically does not have to test for equality. It just makes sure that the order is not altered unless the second is strictly less than the first.
12:20:20
beach
Speaking of which, there is a related project that could result in an ELS paper. It is known that merge sort (which is stable) is faster than quicksort (which is not). But naive merge sort requires O(n) additional memory to sort a vector (but not a list). There are research papers that turn that into O(1) but at a cost. The project is to implement merge sort on vectors by checking whether there is available space on the stack. If
12:20:20
beach
so, use it to make merge sort fast. If not, use one of the published algorithms to make it correct but slower.
12:31:55
beach
shka, jmercouris: now that I think about it. Those papers may not be available for free, so be careful what you do with them.
12:34:38
beach
shka: Sure. Still, someone needs to write the tests and compare to the SORT implementations of various Common Lisp systems. There is plenty of non-academic work in a paper like that.
12:36:14
jkordani
beach: that sounds interesting to me too. but how can it be known how much space is available on the stack?
12:36:44
beach
jkordani: I am pretty sure your Common Lisp implementation has a way of telling you. I know SBCL does.
12:37:33
jkordani
in hindsight I suppose that it is known/enforced by the os so I guess I shouldn't be surprised that there is a way for a program to discover the limit
12:38:11
beach
jkordani: And in the case of SBCL, I believe the default stack size is fixed by SBCL itself. It is per thread.
12:39:39
beach
Now you are asking me to remember that. No way. Let me see whether I can dig it up...
12:40:20
schweers
beach: I thought you knew it off the top of your head, don’t go to too much effort just to satisfy my curiosity please.
12:40:48
beach
OK. I'll see if it is the paper we wrote about processing lists in reverse order. Hold on...
12:43:45
beach
schweers: sb-vm:*conrol-stack-end* sb-vm:*control-stack-start* sb-kernel:control-stack-usage is what I see in our code.
12:45:17
beach
so you do (- sb-vm:*control-stack-end* sb-vm:*control-stack-start* (sb-kernel::control-stack-usage))
12:46:38
schweers
oh, control-stack-usage is not external. that explains why I couldn’t find it at first
14:28:24
beach
loke: I have invented a synchronization protocol for the garbage collectors of SICL. If you feel like reading it, here it is: http://metamodular.com/garbage-collection.pdf
14:28:42
beach
loke: I included the entire chapter, because it explains the different techniques as well.
14:29:17
beach
loke: I am not a synchronization expert. There might be simplifications possible, using (say) condition variables rather than semaphores.
14:30:02
beach
loke: The chapter is not entirely complete. I have yet to describe locking in the global collector as a result of promotion requests and as a result of using multiple threads for the global collector.
14:30:50
beach
Anyone else who would like to read it is of course welcome to do so. I take questions and requests for improvements as usual.
14:31:52
Bike
this isn't directly related, but how are conses recognized if they don't have a class pointer?
14:34:58
Bike
and racks don't move. the only time you'd need to resize one is for change-class, but you can just allocate a new rack instead and actually sorta have to, so there's no problem
14:38:00
beach
A checks the size, then gets blocked. B shrinks the array. A wakes up and sets an element outside the array.
14:38:26
flip214
what's the easiest way to get an (array (unsigned-byte 8) *) MSB-filled from a bigint? a loop with LDB, or is there a faster way?
14:41:31
beach
In SICL, the plan is that A checks the size which is stored in the rack and the rack does not change its size. B shrinks the array by allocating a new rack. It then uses the CAS operation to install the new rack. A needs to access the rack again only after a call to an external function, or in an infinite loop.
14:42:25
beach
So does Clasp have a lock for every array access? Or is it just not thread safe? Or some other solution that I can't think of?
14:50:44
jackdaniel
afaik Jose's idea about thread-safety was that programmer is responsible for locking access when appropriate (and since drmeister reimplemented same algorithms in C++ initially, that behavior is inherited)
14:51:39
beach
There is also the fact that "thread safety" means different things for different people.
14:52:33
drmeister
I think we could add thread safety by making the type that points to the rack and the rack slots to atomic.
14:52:42
beach
But it can give the wrong answer in some situations unless the programmer take precautions.
14:59:01
drmeister
I can't answer at the moment - I'll need to think hard about what you proposed and what I'm thinking.
15:50:44
beach
Suppose I wanted to implement Clordane for SBCL, or rather, for SBCL code compiled with a Cleavir-based compiler, so that I can control precisely what that code does. I translate to HIR, then back to a simpler Common Lisp that I compile with the native SBCL compiler. But the resulting code is supposed to interrogate a table in the thread structure say before and after each form to evaluate.
15:50:57
pjb
loke: message passing was what was envisionned originally by Alan Kay. Unfortunately, he named it object-oriented, and the first implementations used function calls, so all went awry. The difference is that function calls are synchronous, while message passing is asynchronous: the sender doesn't wait for the recipient to process th message. This is not necessarily related to multi-threading or multi-processing, and if you have
15:51:34
beach
Now, SBCL represents threads with structure objects, so I can't change-class if I want to add more stuff to them. Do I need to modify the source of SBCL to make this work.
15:51:44
pjb
loke: when objects are restricted to a single thread, they're called "monitors". Then they're the focal point of synchronisation, since processing their messages is mutually-exclusive.