freenode/lisp - IRC Chatlog
Search
5:15:35
no-defun-allowed
I looked at https://irclog.tymoon.eu/freenode/%23lisp?from=2018-11-26T00%3A14%3A11&to=2019-11-26T12%3A14%3A11&search=Lisp%20System%20Implementation&by#
5:22:04
anlsh
Thanks! Seems like the discussion hasn't been extensive, so I'll have to try to catch beach sometime
5:34:25
ebrasca
aeth: I have installed sbcl on my talos II, but I can't make it work with multithreading.
6:13:45
aeth
I think no-defun-allowed was also involved in the discussion iirc and no-defun-allowed knows the threading libraries.
6:15:21
aeth
me niether, but the benchmark would be simple. 1 thread, n threads (where n is number of cores), n*2 threads, n*4 threads (because power has 4-way SMT)
6:20:03
beach
anlsh: A lot of the book contains C code, and the strategy for implementing memory allocation is very different from what most implementations would do.
6:20:48
beach
I had hoped that it would discuss pros and cons with different implementation strategies, but it is basically just the code of one particular implementation.
6:25:09
anlsh
I see. As to the "too much C" complaint, were you hoping the author would bootstrap earlier?
6:26:17
beach
Well, I was hoping for an insight into different strategies. Among them, a strategy where everything is written in Common Lisp, and the pros and cons of that one.
6:27:39
beach
The title of the book suggested that. But, like I said, it is basically just the commented code of one particular implementation.
6:32:00
beach
anlsh: If the goal is to create a general-purpose Common Lisp implementation, today there is no particular reason to write it in a language other than Common Lisp.
6:33:49
anlsh
Thanks, I think you're right in that we're trying to get different things from the book. Follow-up, how much experience did you have with the topics in the book beforehand? I don't have any experience with compilers, and am wondering how approachable it would be
6:34:42
beach
I think it is fairly easy to understand. But it doesn't give any insight into different ways of creating a Common Lisp system.
6:35:35
beach
I am writing SICL at the moment, so I already have experience with different implementation strategies.
6:36:25
beach
anlsh: You would learn more about the pros and cons of different strategies by asking in #sicl than by reading that book.
6:36:42
anlsh
Yeah, my interest it is definitely from a different perspective. I was hoping to use it as an introduction to language implementation in general
6:37:58
beach
But if you don't have too many budget restrictions, go ahead and buy it just to check it out.
6:41:25
anlsh
Well, if it's not usable as an intro text to implementation stuff then I'll hold off for now
6:42:11
beach
Sure. Again, if you want to discuss different strategies, go ahead and do it here or in #sicl.
6:48:15
beach
anlsh: For example, most existing implementations were started before CLOS was part of the standard, so they all incorporate CLOS very late in the build process. I think that with a new implementation, that strategy is not a good one.
6:49:12
beach
Even SBCL suffers from that problem. The compiler is written without the use of generic functions.
6:53:01
beach
For instance, SICL can use DEFCLASS to define the class SYMBOL, but if you don't have CLOS, you have to define it differently.
8:54:32
lukego
I'm reading the ASDF docs but I'm still not sure what it is I'm supposed to do nowadays instead of pushing a directory onto ASDF:*CENTRAL-REGISTRY* to programmatically add a a directory to be searched for .asd systems?
8:57:40
jackdaniel
asdf looks for some magic config files where you may specify what is put where, afair it is described in a manual (but poorly written)
9:34:51
lukego
Situation is that I've used Quicklisp to create a "bundle" of all my dependencies, and setup the Lisp startup env to find all of those, but now I want to add the *.asd that live in my source tree somehow. These systems aren't really "installed" and so I don't have the linked from standard paths and configuration files. Maybe what I need is a custom lisp.sh that makes them findable at startup and use that as inferior-lisp-p
9:36:11
lukego
... So at runtime I don't have Quicklisp and I also don't want to hack well-known files in ~/ etc.
9:36:38
lukego
but actually the custom startup script will be fine, I'm already doing that anyway and just hadn't thought to plug in my systems there.
9:37:45
lukego
I've gone "full nix" and made a little distro of all the Lisp and Emacs packages that I need, and their configurations, using the nix tooling that grovels Quicklisp and MELPA. Seems to work surprisingly well now.
9:55:53
scymtym
lukego: i didn't catch whether you still it, but something like (asdf:initialize-source-registry '(:source-registry (:tree "/path/to/tree") (:tree "/path/to/directory/") :ignore-inherited-configuration)) configures the source registry programmatically
9:56:56
lukego
I really just want to add a path without disturbing what's already there, since that was painstakingly setup by some cl-wrapper.sh script that I didn't write and am only starting to understand now
10:08:42
jdz
lukego: There is also CL_SOURCE_REGISTRY environment variable (if you have not already seen it).
10:09:46
lukego
Thanks. I'm trying now with NIX_LISP_ASDF_PATHS that the nix common lisp wrapper seems to turn into :TREE paths for asdf. However they don't seem to be getting picked up and I'm not clear on how to ask ASDF exactly what its complete set of search paths is at runtime?
10:10:50
jdz
I remember struggling with this as well, and ended up using CL_SOURCE_REGISTRY, but exact details of my struggles evade me...
10:12:10
lukego
I'm concerned that this variable might be clobbered by the wrapper, but here goes nothing...
11:17:37
lukego
I'm looking for but not finding information about how to make org-babel start SLIME session(s) by itself. I feel like I've seen this on the interwebs before though?
11:23:28
lukego
I mean that if I open Emacs, and open a .org file with Lisp source, and press `C-c C-c' to try and build it, then it complains that no SLIME session is available to evaluate the Lisp code. So I need to do `M-x slime' first. But I have the impression that org is able to manage one or more sessions on it own? (Or maybe it only does that with other languages, I don't quite recall.)
11:26:35
lukego
(This is not something important, I can easily live without, just had a memory fragment of having seen a HOWTO once upon a time and not finding it again now. Could have been for e.g. R rather than Lisp or something though.)
11:29:30
oni-on-ion
https://emacs.stackexchange.com/questions/26142/is-it-possible-to-open-file-then-load-slime-automatically ?
11:38:49
_death
you can change org-babel-lisp-eval-fn to your own function that starts slime if necessary
12:11:50
easye
lukego: RE: ASDF, I've been experimentally <https://github.com/armedbear/abcl/blob/master/ci/asdf-finds-abcl.bash> creating a DSL file for every ASDF system I want to access.
12:12:27
easye
Having everything on the filesystem allows me to quickly M-x ag introspect what is currently available by invoking ASDF:INITIALIZE-SOURCE-REGISTRY
12:13:40
easye
And for patches to Quicklisp, it is sufficient to git clone things into <file:~/quicklisp/localprojects/> <https://github.com/armedbear/abcl/blob/master/.travis.yml#L43>
12:38:23
phoe
http://www.lispworks.com/documentation/HyperSpec/Body/f_string.htm tells me nothing about this.
12:41:38
phoe
There is an ANSI-TEST that assumes that it must be fresh every single time, and it fails on CCL.
12:49:12
jackdaniel
assuming that the same string may be returned, what about (%f) (setf (svref str 0) #\d) (%f) ;?
12:50:00
_death
if the result EQ is expected to be true then it assumes the string is not fresh.. I don't think you can assume either way, so you treat it as if it wasn't.. same for COERCE
12:50:27
phoe
_death: ideally I'd want the passage from the spec that says that the produced objects must be fresh
12:50:45
phoe
because in theory #'COERCE could cache its results and return them if the objects need not be fresh
12:51:21
easye
Aren't strings implicitly static objects for implementations? It's true for abcl as they thunk down to java.lang.String references.
12:55:27
flip214
I'm trying to use named-readtables. In my code I have (let ((*readtable* (copy-readtable))) (named-readtable:in-readtable :mine) (ignore-errors ...))) but still that readtable is used in the next commands sent via slime - which breaks parsing, of course.
12:56:19
phoe
I've annotated this paste with one more. If you use (string #\a) that is not wrapped in a function call, then a fresh string is produced.
12:56:33
trittweiler
flip214, in-readtable modifies a slime variable associating a package with a readtable. It has a global side-effect that way
12:58:27
trittweiler
flip214, sly (https://github.com/joaotavora/sly) I believe has proper support for named-readtables. Which means it looks for a contextual in-readtable form (like Slime does for in-package) and makes sure to send that to swank when evaluating.
12:58:37
jackdaniel
literal objects are described as either quoted or self-evaluating, so it would not be conforming for stadard function to return a literal object, no?
13:00:36
jackdaniel
but you've got a point, there are functions which may return literal objects. but I'd expect their specification to have such warning
13:03:18
_death
phoe: (ok, I figured out deftest syntax..) note that in the other cases STRING can return such objects.. the string itself as shinmera noted, or the symbol's name, which as you note should not be modified.. so it makes sense to expect that the string (string #\X) should also be treated as such, given that there's no special wording to contradict
13:03:24
jackdaniel
also what symbol name returns is not literal objects but rather internal state of the symbol object
13:04:25
Bike
"literal" means it literally appears in the code, using it to mean "can't be modified" is confusing
13:06:13
jackdaniel
the thing is that spec doesn't say, that returned object from character is immutable, but when you mutate it function starts to return incorrect results
13:07:09
jackdaniel
phoe: see above ^ #'string may start to return incorrect results in code which is not non-conforming
13:07:27
phoe
but a FLET function with optimize speed 3 everything-else 0 that calls (string #\a) is constant-folded into "a"
13:09:03
jackdaniel
phoe: there is nothing in spec, that you can't modify result of (string #\a), so you are not forbidden to modify it
13:09:24
jackdaniel
when you mutate resulting string and subsequent call (string #\a) returns something else than "a", then it is incorrect result
13:10:06
_death
disagree.. since it doesn't claim the string to be fresh, you could have a compiler macro that expands to "X" on form (string #\X)
13:10:13
jackdaniel
seems so. I would be more unsure in case of symbol passed to string - should it copy the symbol's name?
13:10:28
jackdaniel
because it is not said it calls (symbol-name ...) hence there is no restriction on immutability
13:13:11
Bike
these kinds of issues are precisely annoying to deal with because without real cases of it coming up it's just abstract
13:20:49
phoe
one second though - is an implementation allowed to constant-fold something that is not constantp?
13:21:41
Bike
constantp isn't even sufficient to describe all the constant folding a compiler can do since it can't know about lexical variables that happen to be constants, etc.
13:41:56
pjb
phoe: check again: (flet ((%f () (string #\a))) (let ((x (%f))) (setf (char x 0) #\d) (list x (%f)))) #| --> ("d" "a") |#
13:43:19
pjb
(lisp-implementation-version) #| --> "Version 1.12-dev (v1.12-dev.4-4-gd9740256) Darwinx8664" |#
13:45:56
phoe
https://github.com/Clozure/ccl/commit/d2174411c72d9208f1c081632cce6996448bc68a#diff-7dbee25941139b1e1582d8f0c87f1b23
13:46:17
flip214
trittweiler: phoe: so I can't use named-readtables to programmatically read and parse text data? there's no WITH-NAMED-READTABLE, sadly.
13:48:43
phoe
_death: thanks for that link, this is the commit that states that #'STRING can always be constant-folded
13:48:55
trittweiler
flip214, (it's most likely preferable to use ensure-readtable rather than find-readtable)
13:49:25
flip214
trittweiler: well, the readtable is defined just a few lines above, so there should be no difference in practice
13:51:01
_death
phoe: what's strange is that sbcl has deftransforms for string/symbol case but not for character..
13:52:54
_death
phoe: it's strange to me that it doesn't have a deftransform returning a string literal
13:54:51
phoe
pjb: it doesn't also formally say that the consequences are undefined if that string is modified
13:55:29
phoe
jmercouris: because two different restarts have been established in various places of the stack
13:55:35
pjb
phoe: note that in the case of (string #1="x") it's #1# that is returned, not a fresh string (not a copy).
13:56:35
phoe
pjb: if we want consistency, then #'STRING may return non-fresh values and the ansi-test is wrong
13:57:26
trittweiler
which would be the upper one, assuming they are displayed by sorting top-to-bottom
13:59:46
phoe
my question by now is - since this tests succeeds only if #'STRING returns *fresh* values, where in the spec is it specified that #'STRING must return *fresh* values
14:01:34
pjb
phoe: that's the point; it's not formally specified. "fresh" doesn't occur on this clhs page.
14:02:24
flip214
I do (:syntax-from :common-lisp #\( #'<) so that the string "(1,2,3<") is correctly parsed as a list -- but the reader says "unmatched close parenthesis" there. How can I fake the end of a list then?
14:03:57
jmercouris
trittweiler: well, the strings are exactly the same, I can't exactly know without actually looking with the inspector
14:04:13
pjb
flip214: emacs will colorize the string so you can see what's inside and what's outside!!!
14:05:57
trittweiler
flip214, what phoe says. Define your own reader macro function for #\< which uses read-delimited listwith #\>
14:06:00
pjb
ok, in that case, I guess you assume that (:syntax-from :common-lisp #\( #'<) means define a reader macro on #\( to read-delimited-list with comma and #\<…
14:06:08
flip214
phoe: thanks; I could also have #\) as the list terminator, so I can't call read-delimited-list myself
14:06:39
trittweiler
yeah then you really need to write a function that does the parsing yourself :)
14:06:53
jmercouris
Save time, write a parser that writes parsers so you never have to write a parser again
14:06:53
flip214
pjb: I hoped that I can just "copy" the behaviour from #\) to #\<, but that's not so easy.
14:07:46
pjb
The trick of lisp is the Polish notation: the first character determines the syntax, the first symbol determins the semantics.
14:08:18
flip214
this is "parsing" the strace argument list; and so I have to handle "<... unfinished>"
14:08:23
phoe
flip214: you can't use READ-DELIMITED-LIST then since it expects a single closing char.
14:08:43
flip214
I was able to redefine , to be the delimiter character, and to ignore spaces after it
14:29:56
phoe
jackdaniel: the spec doesn't say that the return value is mutable and it doesn't say that the return value is immutable
14:44:26
jackdaniel
phoe: taking that line of thought renders string produced with with make-string foldable
14:45:15
jackdaniel
while I agree that it is not said whether it is a fresh object or not, there is no indication that modifying the result is an undefined behavior releasing nasal deamons
14:48:18
phoe
jackdaniel: you are correct, make-string is supposed to be the function for consing up new strings
14:49:31
phoe
so it seems that the only possible choice that doesn't conflict with (string #\a) returning "d" is to make #'STRING always return fresh strings for characters
14:51:19
jackdaniel
in case of a symbol name I would argue that it is necessary to return a fresh string
14:52:19
jackdaniel
it is not said, that it returns the same thing as symbol-name does (or that it calls symbol-name)
14:55:12
jackdaniel
specification: yyy returns "42". modifying string has undefined consequences. vs. zzz returns "42".
14:55:57
phoe
if we read it that way, it becomes obligatory that (symbol-name :foo) is NOT eq to (string :foo)
14:56:26
pfdietz
On the issue of strings in the standard: an implementation is allowed to turn string constants into strings with restricted element types. "foo" can be turned into a simple-base-string, for example.
14:56:26
jackdaniel
undefined consequences in symbol-name doesn't prohibit it from returing fresh string
14:56:54
jmercouris
let's say I am at a parenthesis and I want to jump to the corresponding parenthesis, how can I do that?
14:56:54
phoe
pfdietz: that's a different issue though, subtyping strings into more specialized strings
14:58:25
pfdietz
I forget, alas. It was in a test case where a string constant is copied, then a non-base-char is assigned into the copy.
15:01:29
_death
phoe: when I started using stumpwm I found it strange that it used C-t for prefix.. immediately switched it to C-z
15:03:47
pfdietz
Is there a library for exploding a set of functions into versions specialized on particular subtypes of the arguments? This comes up in some string handling code, where I want it to take advantge of some large string being simple and of a particular element type.
15:14:15
jackdaniel
pfdietz: few mcclim functions do sometething like (macrolet (thunk () ...) (typecase foo (a (thunk)) (b (thunk))))
15:20:27
jmercouris
I've seen the term used a lot, I've looked at the definition, and I still don't get it
15:21:42
_death
just something you jump to without thinking.. it's been "thunk".. or, a function taking zero args that usually delegates to another thing
15:23:26
jackdaniel
in sources I saw it is sometimes used as a macro name in macrolet to name something without a name
15:23:58
jackdaniel
(so strictly speaking in a snippet I've shared above it is not a function but a macro)
15:30:31
jmercouris
That sounds terrible, not sure why you wouldn't just use a defparameter or something if you need a compile time evaluation on the toplevel
15:31:45
pfdietz
I have actually had need for thunks in CL recently. The issue was redefining a function that was defined in a nontrivial lexical environment. To capture that environment, one creates thunks.