freenode/#lisp - IRC Chatlog
Search
5:01:47
Elronnd
oni-on-ion: I haven't, might just use that. Form is a bit different than I'd like, but eh
5:02:03
aeth
Elronnd: You don't have to balance anything complicated because you're using streams with this approach, so you just need to make sure that the macros generate the calls to the stream writing functions so that they get called at the right time.
5:02:53
aeth
Actually, the latter approach with the inner format probably wouldn't work as well as the earlier outer format one I posted, because you can make the entire format string at compile time.
5:02:54
Elronnd
wait, why can tail recursion blow the stack? Doesn't it mean that any additional tail calls consume no stack?
5:04:32
aeth
Elronnd: Tail recursion isn't guaranteed to be optimized in CL, unlike in Scheme. It could be, but it probably not at (optimize (debug 3))
5:06:45
aeth
Anyway, what I would do is generate this format string at compile time in a macro (note that if you don't use format you can use ~A and if you do you have to escape it with ~~A): (with-output-to-string (output) (write-line "<html>" output) (write-line "<body>" output) (write-line "Hello, ~A!" output) (write-line "</body>" output) (write-line "</html>" output))
5:07:21
aeth
If you generate each pair at the same time and then work on the middle, you can keep the tags balanced
5:07:35
Inline
only to the extent of adding to it for new stuff (all the stuff that has to be pushed there anyway), not for pushing the same stuff over and over
5:08:25
Inline
instead of pushing the same stuff over and over it reserves only one stack entry and reuses that over and over
5:09:08
jasom
oni-on-ion: tail calls reuse the stack frame; for the specific case of a self-call that means zero extra space; it might use *less* space if the tail call is to a function with a smaller stack frame.
5:09:47
aeth
loke: looks like this is finally a use for formatter, since the pattern to generate with the macro is (lambda (...) (format ...))
5:10:19
oni-on-ion
jasom: ah, right ^_^ was a bit confused where it was said to grow and also stay the same.
5:11:01
ealfonso
I asked this ealier but I was disconnected. Is it a bad idea to have export declarations per-file via the export function, as opposed to within a defpackage form? I heard something was being deprecated?
5:11:23
Inline
and the frame size change may be due to the recursion step doing two different branches tail wise
5:11:48
loke
ealfonso: In such cases, I'd recommend you put the DEFPACKAGE form in the head of the file, and include an :EXPORTS section in the DEFPACKAGE.
5:12:14
aeth
Elronnd: So your macro could look something like this: (defmacro generate-the-html (...) `(formatter ,(with-output-to-string (output) ...)))
5:12:42
aeth
Then you just need to write to the stream in the right order, doing what you can at macro time and saving the rest for the format string
5:12:43
jasom
ealfonso: not being in the defpackage may cause issues if you have to recompile the defpackage form.
5:13:08
loke
Having it in defpackage is also useful when using SLIME, as it can manage it automatically for you.
5:13:15
ealfonso
jasom yes, I think this is what I am finding. I will just put everything in defpackage
5:13:28
loke
ealfonso: Then I suggest you put it in a separate files (most systems seems to use package.lisp)
5:13:59
loke
ealfonso: But keep the exports in the defpackage, as otherwise SLIEM will get confused, and recompiling will cause problems, sometimes.
5:14:32
loke
Inline: you have to separate what CL says, vs. what implementations do. The CL spec never discusses the concept of the heap.
5:15:22
loke
Inline: A CL implementation is free to implement the spec in any way they want, as long as it does what the spec says.
5:16:46
jasom
Inline: for a typical C implementation automatic storage means stack, and malloc() means heap.
5:18:05
jasom
but the C standard doesn't mention stack or heap either, so that's still just implementations
5:18:52
aeth
The CL standard mentions the stack, in dynamic-extent. http://www.lispworks.com/documentation/HyperSpec/Body/d_dynami.htm
5:21:41
jasom
in general stack is increment pointer to allocate, decrement pointer to free, and heap the allocation and free need not happen in any specific order.
5:24:04
jasom
Inline: endian has nothing to do with it; it's a question of whether you increment to allocate or decrement to allocate
5:25:24
jasom
the ABI defines things like whether stack grows up or down and how parameters are passed. Certain ISAs lend themselves to stack growing up or down because they have e.g. a "call" instruction or push/pop instructions.
5:31:06
russellw
I'm trying to send all console output to log file, using a broadcast stream. This mostly works. *standard-output* gets stuff I print myself, *trace-output* gets output of TIME, *error-output* gets most error messages. But when SBCL runs out of memory, it prints a table of garbage collection info that does not get captured. How can I capture that?
5:37:20
russellw
jasom, that is the page I was looking at, I've covered every output stream. What am I missing? Do I also need to somehow cover the bidirectional ones?
5:41:41
jackdaniel
russellw: did you consider using log4cl? it has a concept of appenders and log levels
5:42:50
russellw
jackdaniel, not necessary, thank you, I already have the log running fine. The issue is how to make all the system code output to my log
5:43:58
russellw
Inline, to my pleasant surprise, assigning an output stream to query-io and debug-io, works – it does not crash the program or anything. But unfortunately it does not capture the GC error output
5:49:57
jasom
russellw: the GC error output is almost certainly not written in lisp and probably uses file streams
5:50:45
Inline
(defun gc-logfile () "Return the pathname used to log garbage collections. Can be SETF.
5:50:45
Inline
designated file is opened before and after each collection, and generation statistics are appended to it."....
5:53:30
Inline
(!defvar *after-gc-hooks* nil "Called after each garbage collection, except for garbage collections
5:53:30
Inline
triggered during thread exits. In a multithreaded environment these hooks may run in any thread.")
6:10:47
another-user
i tried to use this reader macro https://gist.github.com/rmoritz/1044553/b2d2d8e4b933cb0f6c3fb5ff3f9bcfae6be7ce47 and it works in sbcl repl
7:00:23
LdBeth
And these reader macros are not idiomatic, bacause (quote [1 2 3]) is supposed to return #(1 2 3)
7:53:30
another-user
shka_: do you mean instead of {} macro i should create #{} kind of macro? but how?
7:56:42
another-user
shka_: i need this https://gist.github.com/rmoritz/1044553/b2d2d8e4b933cb0f6c3fb5ff3f9bcfae6be7ce47 to work in slime repl
7:58:36
kristof
this is so minor but those lambdas don't have to be indented so far; only two spaces after set-macro-character
8:00:05
kristof
Also, and this is my limited experience, but I've never really wanted hash literals. Hash tables have advantages for multitudinous collections
8:00:27
jdz
Also, pretty sure READ-DELIMITED-LIST can be used instead of creating new readtables on every invocation.
8:00:29
kristof
But for small collections, which is what I'd what literals for, plists outperform the hashing overhead, usually
8:02:14
jdz
another-user: if the calls to SET-MACRO-CHARACTER are done in the REPL then they should be working.
8:11:51
jdz
another-user: I re-wrote the square bracket reader: https://gist.github.com/jdz/89b93653da3c3fe965a904b67cec5e43
9:35:10
svillemot
Myon: I've investigated your pgloader issue, and the problem comes from cl-ironclad which is out-of-date in Debian
9:37:28
dim
svillemot: I've been told (here) that the compile time difficulties are also solved with the most recent version of SBCL
9:39:29
svillemot
actually it's *because* SBCL is recent that we have problems with nibbles and now ironclad, because those project use SBCL internals, and needs updating
9:40:42
dim
while you're around, would it be a good idea that I spend time trying alternatives to cl+ssl/openssl for pgloader, maybe using bearssl or wolfssl or some other lib that would make our life easier?
9:42:30
svillemot
the cl+ssl situation is now ok on the Debian side, but only because I patched it for OpenSSL 1.1
9:43:05
svillemot
diverging from upstream is not ideal, so if there are other projects which have native support for OpenSSL 1.1, that could be interesting
9:43:24
dim
my limited understanding of the problems is that openssl itself plays tricks with the way it exports symbols, other ssl libs might be clean on that aspect
9:45:14
svillemot
wolfssl seems promising and is packaged; that does not seem to be the case for bearssl
9:46:30
dim
otherwise there's always https://github.com/shrdlu68/cl-tls/ but well I'm worried about using non well tested implementations of should-be-secure stuff
10:00:06
dim
I can find https://github.com/mak08/PolarCL which depends on cl-mbedtls... but for now I can't that that system
11:11:26
Xach
I wish all implementations provided and maintained good ways to make secure connections on every platform they support.
11:38:41
jcowan
Proper tail recursion does not require constant stack, only asymptotically constant stack.
11:40:37
jcowan
Specifically, the implementation must support an unbounded number of active tail calls. How it does that, as always, can vary.
11:42:57
beach
ggole: Can you elaborate? I mean, if they are not reused, the heap will be exhausted rather than the stack.
12:55:41
jmercouris
let's say I have path like #P"/Users/username/file.txt", how can I get "file.txt"?
12:56:04
jmercouris
I was thinking of uiop:unix-namestring and then doing some string parsing, but I figured there must be a better way
14:39:55
jmercouris
I think an obvious starting point might be "is this function used anywhere else"?
14:41:22
antoszka
I don't think I've ever gave it anymore attention than what you've already said. It's this and *maybe* sometimes I'd split a function out for better readability.
14:44:06
jmercouris
so you can use flet to return a function that has the contxt of a parent function, like some sort of closure factory?
14:45:01
pfdietz
Yes, function values (lambdas, too) can cause the context to be preserved, even after the parent function returns.
15:00:00
jcowan
A simple case. There are many functions in CL that take functional arguments, the most ordinary case being map, which passes the elements of a sequence through a function in order to form a sequence of the results.
15:04:58
jcowan
It's not uncommon for the function you pass to involve some of the local context of the call, as in (map 'list (lambda (x) (eq? x y)) some-list)
15:05:55
jcowan
This will return a list of booleans indicating whether each member of some-list is the same object as whatever y may be.
15:08:53
Shinmera
Is there a standard way of determining whether a float is negative? (keep in mind the case of -0.0)
15:13:07
pfdietz
(let ((x -0.0)) (and (<= x 0.0) (not (eql x 0.0)))) ==> T if -0.0 and 0.0 are "different"
15:15:06
Shinmera
The spec mentions this explicitly even: If an implementation supports positive and negative zeros as distinct values, then (eql 0.0 -0.0) returns false. Otherwise, when the syntax -0.0 is read it is interpreted as the value 0.0, and so (eql 0.0 -0.0) returns true.
15:15:16
jcowan
Another approach is to rely on the fact that (sqrt -1+0i) is i, whereas (sqrt -1-0i is -i)
15:18:44
jcowan
A less heavyweight approach is to take 3/x where x is 0.0 or -0.0, which will produce +inf.0 and -inf.0 respectively
15:21:05
jcowan
The spec allows (/ 3.0 0.0) to return +inf.0 (or however you want to spell it) rather than an exception