libera/#commonlisp - IRC Chatlog
Search
8:46:03
specbot
Additional Constraints on Externalizable Objects: http://www.lispworks.com/reference/HyperSpec/Body/03_bdd.htm
8:55:07
jackdaniel
I wouldn't say that these restrictions are severe enough to say that "fasl must be loaded almost immediety after being compiled [...]"
8:58:19
jackdaniel
on the other hand this restriction is one of major factors regarding the speed of loading fasls - all symbols and packages must be resolved during the load time
9:02:50
jackdaniel
yes, for example loading asdf.fas on ecl takes a few seconds (compared to 50ms without it) - a lot of it is about creating symbols if I remember correctly, but also creating classes etc
9:04:37
jackdaniel
(save-lisp-and-die greatly mitigates this kind of issues, a feature ecl doesn't have sadly)
9:06:23
beach
I wasn't referring to just the difference in performance between the two. I was referring to the role that loading code represents to either the user of a program or a project. And yes, I was assuming that the image would be saved in a final application.
9:14:08
beach
jackdaniel: Also I am confused. Are you saying loading asdf.fas (which I assume is a FASL file) takes a few seconds? But then what does 50ms refer to?
9:20:26
jackdaniel
usually people require asdf at startup; I was referring to startup: without asdf - up to 50ms, with asdf - a few seconds; so I was referring the startup time
9:22:34
jackdaniel
regarding how useful it is to have precompiled fasl - startup of an environment for developing a program that has precompiled dependencies than loading and compiling everything from scratch; admittedly if someone never restarts the lisp process then it is only a minor nuisance
9:40:03
scymtym
::notify junkrunner i was away from the computer for a day and a bit. i don't use discord, so it's probably best to leave a message with the bots as phoe suggested
9:49:07
scymtym
jackdaniel: does the time for "startup with asdf" include asdf initialization? at least with my setup, asdf initialization dwarfs everything else, including loading asdf, because the initialization traverses a directory hierarchy
10:19:54
beach
There was an interesting article in a recent CACM about the mismatch between a modern programming language and relational databases. The authors preferred to create their own persistence library for Java than to interface with a database.
11:13:57
AadVersteden[m]
https://github.com/madnificent/fridge with related libraries https://github.com/madnificent/database-migrations https://github.com/madnificent/cl-validations https://github.com/madnificent/versioned-objects
11:18:20
AadVersteden[m]
The readme is best viewed by source, perhaps formatting on GitHub has changed or perhaps I didn't know at the time.
11:52:45
contrapunctus
AadVersteden[m]: PR created. I usually like to specify the language of source code blocks so they can be syntax highlighted, but I couldn't find a way to do that in Textile. Also, I'm new to both Fridge and Textile, so hopefully any errors I made are still outweighed by the benefits. ^^'
11:58:13
AadVersteden[m]
contrapunctus: That's super kind of you :D Not sure it's the best code but it is more approachable this way.
14:32:12
pve
Hi, if read-char reaches eof and returns an eof value (i.e. eof-error-p is nil), am I allowed to call unread-char with the last character read from the stream?
14:35:39
beach
Reading the dictionary entry on READ-CHAR, I don't find anything that says you wouldn't be allowed to do that.
14:36:55
pve
unread-char says "Invoking peek-char or read-char commits all previous characters". Does that mean I'm not allowed?
14:40:38
beach
"The consequences of invoking unread-char on any character preceding that which is returned by peek-char ... are unspecified"
14:40:49
phoe
I understand it as "if you read char A, then you can call (UNREAD-CHAR A) iff you have not called READ-CHAR or PEEK-CHAR on the same stream"
14:41:14
phoe
so if READ-CHAR returns some character A, and then you call READ-CHAR again, you can no longer (UNREAD-CHAR A)
14:41:53
beach
That's correct. But it also says that if you READ-CHAR an A and then call PEEK-CHAR which returns B, then you can't unread A.
14:42:15
phoe
pve: it doesn't seem like the return value matters, what matters is the fact that you call READ-CHAR *at all*
14:44:15
pve
ok, my thinking was that the "position" in the stream doesn't advance if we reach eof, so the character might still be eligible for unread-char..
14:48:25
phoe
so a string stream could work differently than a network stream or a file stream or terminal stream or some Gray stream or what not
14:50:14
beach
Technically, they can do what they want because it says "Exceptional Situations: None."
15:06:48
jackdaniel
for some streams unreading the character is like decrementing a pointer; while on other streams it is storing the last character in a variable
15:18:23
Bike
i checked C for comparison, and it looks like ungetc doesn't require that the ungot character was the last read, and also it explicitly clears eof
15:47:04
nij-
For example, after hacking #'apply, can I make (3 (list 1 2)) evaluates to ((1 2) (1 2) (1 2)).
15:48:00
Bike
no, i mean that it has undefined consequences, and no implementation does things in the way you apparently expect them to work
15:49:38
Bike
and of course you can define a macro copy such that (copy 3 (list 1 2)) => ((1 2) (1 2) (1 2))
15:51:41
beach
The language itself is not "hackable". You are not allowed to redefine any standard operator.
15:52:28
pjb
pve: you could use (setf stream (make-concatenated-stream (make-string-input-stream "WHAT YOU WANT TO 'UNREAD'") stream)) to 'unread' more than 1 character.
15:52:33
nij-
And not only that, Bike said even if #'apply is changed, I won't get what I want either.
15:52:44
ecraven
nij-: well, this is trivial, just write your own eval function that does whatever you want
15:53:06
Bike
the standard does not mandate that all form evaluations go through apply. doing so without some further rules would make it pretty impossible for compilers to optimize anything.
15:53:14
shunter
That said, you have the option to shadow other operators with your own within your own package nij-
15:53:23
Bike
there are systems like racket that do whatever, and there are toy lisps like maru that do let you do this.
15:53:29
nij-
ecraven Do you mean #'eval is called every time? And if I hack it, the evaluator logic changes?
15:54:28
ecraven
you can also (rather simply) write my-repl, which lets you then have a repl with your variant
15:55:57
beach
nij-: The fact that Common Lisp is not hackable is a feature. If it were, as Bike pointed out, it would be very hard to write optimizing compilers, and then everyone would complain that Lisp is slow.
15:57:40
ecraven
some Schemes support what you want. many Schemes support redefining all kinds of things that CL forbids. and many (almost all?) Schemes are much slower than CL (for many reasons, but this is one of them)
15:57:50
Bike
i think there are probably ways the language could be made more extensible without sacrificing performance, or at least not much performance. but it would require more thought than letting people redefine apply.
15:58:36
ecraven
from my playing around with lisp machines (mostly the cadr via usim), that *did* let you redefine deeply system-internal functions, and that can be rather dangerous
15:58:36
pjb
nij-: more generally, you can write a reader macro to replace entirely the lisp reader (parser), and implement your own syntax. So (3 (1 3)) could mean what you want.
15:59:01
phoe
yeah, the fact that only symbols and lambda forms are valid functional operators is kind of a place where the syntax could in theory be extended without sacrificing performance
15:59:23
ecraven
pjb: that's a good point, a reader-macro alone would be sufficient, if it just expanded every (:foo a b c) to (my-ref :foo a b c)
15:59:26
phoe
the language could just delegate to some programmable slow path instead of signalling an error
15:59:29
jackdaniel
generally an approach where you have some static base + programmable part seems to be much saner than skipping the former
16:00:31
pjb
nij-: but more often, you want to mix lisp and your own syntax. see for example, objective-cl: https://groups.google.com/g/comp.lang.lisp/c/AkU0JCnGGAA https://gitlab.com/com-informatimago/com-informatimago/-/blob/master/objcl/documentation.pdf
16:00:38
ecraven
phoe: but hard to generalise, if it's meant to work like clojure, for accessing "slots" of objects.. you'd need to define *all* possible keywords
16:01:21
phoe
ecraven: no no, I mean, if you had (:foo ...) expand into (my-ref :foo ...) then you would exclude the possibility of (defun :foo ...)
16:01:52
nij-
It's ok, I think the easist way is to hack the reader macro, but I may have to type one or two more characters.
16:24:00
beach
As I recall, Fare tried to define functions with names like that for ASDF or UIOP, citing that it was practical that they would always be available. But he had to back down when there were loud protests.
16:25:09
phoe
keywords are a rare global resource and defining stuff on them should be reserved for end users
16:30:38
thuna`
phoe: Right, the answer is keyword. But I had figured they worked similarly to nil and t
16:31:03
phoe
the thing is that T and NIL are from the CL package and by 11.1.2.1.2 you cannot define stuff on them
16:50:30
beach
Slow, but making steady progress. The latest progress by scymtym prompted me to work on Second Climacs a bit, so that his work could be layered on top of Second Climacs.
16:53:09
beach
So what you are seeing is very detailed and very accurate analysis of Common Lisp code at typing speed.
17:07:17
pl
Have a project where I might want to implement a RPC message bus and CORBA would be reasonable option
17:12:31
jeosol
beach: is it evaluating the code as type, or I am not understanding things correctly
17:12:33
beach
The editor is just DREI, so it is not the final deal. The demo is more about the upper layers.
17:13:03
beach
jeosol: It is not evaluating it. But it does some analyses based on the s-expression syntax.
17:14:15
beach
It won't ever generate executable code, but there could be some compilation-like passes added for even better analyses.
17:15:45
beach
In addition to the syntax analysis, scymtym also has a model of the global environment and the package system, so that some top-level forms can be "evaluated" for incremental effects on this global environment model.
17:16:06
jeosol
I seem to recall seeing some editor discussion last week about the state of editors. I only used SLIME+EMACS but did look at Sly, but then went back to my old slime+emacs setup
17:17:10
NotThatRPG_
I wonder if someone can clarify SBCL's interpretation of FUNCTION types. According to a compilation note, it's interpreting my (declaim (ftype (function (t t) fixnum) choice-node-player)) as (FUNCTION (T T) (VALUES FIXNUM &REST T)) Where does the &rest t come from?
17:18:32
Bike
if you mean that it returns exactly one value, instead of fixnum you can use (values fixnum &optional) or, my preference, (values fixnum &rest nil) which i think sbcl will interpret the same way
17:18:34
rainthree
https://stackoverflow.com/questions/9743056/common-lisp-exporting-symbols-from-packages "Of course, one could reach the conclusion, that macros like defstruct lack a feature. Namely, a switch which enables automatic exporting of the accessors etc. they create." (or better: a switch for each accessor :export t or nil) . Is it so ? I know serapeum.export has this, but the drawback is that the code becomes "foreign" to everyone used to the standard
17:18:34
rainthree
way of exporting in the defpackage. The drawback of exporting in the defpackage is that things get go out of sync , it brings extra maintenance burden . I think the best is to use defpackage and to reduce the burden, let the editor help you: "C-c x to export the symbol at point, or even the class and all its accessors with slime-export-class" . Now the only issue is that I'm dealing with cffi:defcstruct and slime doesn't have a function to
17:18:35
rainthree
automatically export the accessors for it. Should I code one myself or you guys have a better solution?
17:19:19
phoe
rainthree: do your own one, I have no idea if cl-annot or cl-annot-revisit has anything for automatic export of defstruct
17:20:35
rainthree
https://github.com/LispCookbook/cl-cookbook/issues/269 it has , but I think it can only export all of them, you cannot individually select which accessor you want to export, and that's not good
17:27:13
NotThatRPG_
Thanks, Bike ! A quick type declaration follow up: am I right in reading the spec as prohibiting declaration of the return type of a generic function? The doc page for `defgeneric` says that there can't be function declarations *inside* the form, but I could read it either way about external declarations.
17:30:30
resttime
If there are any CFFI maintainers lurking, created a PR for a small change meant to be first step in tackling an old bug with libffi and passing a foreign-structure-by-value (FSBV) to a foreign function with variadic args : https://github.com/cffi/cffi/pull/347
17:37:16
Bike
NotThatRPG_: you can declare the return type of a generic function, the same way as you do with other functions - declaim
17:37:35
Bike
NotThatRPG_: the declarations within the defgeneric only pertain to the discriminating function, which is why only optimize is allowed
17:39:22
NotThatRPG_
Bike: I was trying to do that, but according to SBCL "Generic function SHOP3::CHOICE-NODE-PLAYER clobbers an earlier FTYPE proclamation (FUNCTION (T T) (VALUES FIXNUM &REST T)) for the same name with (FUNCTION (T T) *)"
17:40:43
beach
random-nick: No, but there are plans for such a thing: http://metamodular.com/POSIX-API/
17:42:10
NotThatRPG_
Bike: But it seems to imply that the return value declaration is being ignored. For now I'm just putting #-sbcl in front of it.
17:43:55
Bike
you can see what the declaration on the name is with describe. and it does look clobbered if you put the declaim before the defgeneric. how vexing
17:46:58
random-nick
beach: hmm, I guess what I'm looking for would be something like the low-level interface, but I guess I'm interested in some linux-specific system calls
17:47:51
random-nick
regarding the no FFI requirement, wouldn't that cause problems for some newer system calls which use C structs?
17:49:39
rainthree
phoe: I think this is the most convenient solution: https://stackoverflow.com/a/70235441/19589272 show-all-fboundp-symbols-of-package then copy paste or use some editor shortcut such as ctrl+right click on the symbol to add it to the :export list in the defpackage form
17:50:08
beach
random-nick: A C struct is just a sequence of bytes in memory. It is just a matter of figuring out the layout.
17:50:28
beach
Anyway, my (admittedly small) family just announced that dinner is ready, so I'll be off for today.
17:50:39
pjb
But syscalls are just a few hundred functions. The equivalent of the API from libc would be implemented in pure lisp.
17:50:58
pl
random-nick: you need only to port the binary layout into some form of serialisation/deserialisation component that can be pure Lisp
17:52:05
pl
ACTION recalls the joke from Genera sources about implementing considerable chunk of PL/I compiler to do something like that, for mapping data structures into binary records on disk
17:52:31
random-nick
pl: it still has to reside in what is usually called "foreign memory" since CL object don't have any guarantees about how they're laid out in memory afaik
17:53:59
pl
You can have that as implementation specific interface between standard and implementation detail
17:56:02
pl
Similarly, the closest thing to knowing exact layout in standard C is that things in array are laid out in certain way
17:57:08
pl
(and even then it's not guaranteed it will reflect the layout and ops necessary to access them in actual memory, just that it will match other standard C code behaviour)