freenode/#lisp - IRC Chatlog
Search
0:18:53
White_Flame
none comes to mind, but with multiple drives/partitions, the notion needs more specificity
0:23:05
Nilby
I have a thing, but I can't recommend it: (nos:filesystem-info-bytes-free (nos:get-filesystem-info "/"))
0:32:07
Nilby
Typical Lisp reasones: no docs, no tests, 1 user, poorly maintained, capricious developer, etc.
1:15:34
pjb
saturn2: in posix, you would use /bin/df with the path of a item stored on the file system.
1:16:03
pjb
saturn2: but note that file systems are unrelated to disks: a disk may contain several file systems, and a file system may be stored on 0, 1 or more disks.
1:16:46
pjb
saturn2: if you have the access rights, you could try to read the parttion table on the raw disk device, and interpret it to see if there's some free disk space between partitions?
1:35:27
pjb
saturn2: by the time you get the information you believe you need, it may be totally wrong!
1:35:46
pjb
saturn2: another user may have allocated all the remaining space, or another process may have deleted files!
1:36:28
pjb
saturn2: so the only way to do it, and this is the big lesson of unix, and why it has been so successful compared to other OSes old an new, is that you don't want to use such query, but instead you want to do what you want to do, and wait for an error to occur if it's not possible.
1:39:06
pjb
saturn2: you can pre-allocate a file: (handler-case (with-open-file (out "DATA:FILE.BIN" :element-type '(unsigned-byte 8) :direction :output :if-does-not-exist :create :if-exists :error) (loop with buffer = (make-array (* 1024 1024) :element-type '(unsigned-byte 8) :initial-element 42) repeat 1024 do (write-sequence buffer out))) (:no-error () t) (error () nil))
1:40:50
pjb
I one of my first jobs we worked on a system where the admin allocated the files on the disk track-by-track…
1:40:51
Nilby
Another lesson of unix is that doing it that way is completely unreliable, and modern reliable software doesn't. And most unix is single user now.
1:41:48
saturn2
but also, there are other reasons to monitor disk usage than creating a file immediately
1:43:38
pjb
because it's useless to offer all the functions: there are an infinite number of functions!
1:47:44
Nilby
The amount of things people expect from a portable O/S interface is finite, and relatively small, and I think seeing how much disk space you have is surely a useful one.
1:48:03
pjb
But anyways the output of df(1) is human readable, so it cannot be processed easily (format may change).
2:08:29
Nilby
I find it amusing that there's awk in lisp and lisp in awk, but a df in Lisp uses C awk.
3:56:24
beach
For example, calling COPY-LIST on a circular list might do that. At least, the standard allows for it to happen.
3:57:35
asarch
I am using cl-cffi-gtk to create the window using a Glade template file to CRUD the data from a local PostgreSQL cluster using Datafly
3:58:42
asarch
Since I am learning the Japanese language, I was copying/inserting some grammar information into the cluster using this interface
4:01:04
White_Flame
and same as beach, I have no idea about the effects of FFI on the lisp heap. Assuming that any malloc stuff is outside lisp-managed memory space, I wouldn't actually suspect it
4:01:34
asarch
Well, every time the data was inserted the CPU % use increased to the infinity and beyond
4:04:14
asarch
top -d 1 shows the % used of the processors every time I "saved" the new data using this GTK+ application
4:05:47
no-defun-allowed
asarch: Do you have an idea of how much data you are loading into Postgres?
4:06:20
beach
White_Flame: I am sure there is. I am no longer directly involved, but I am sure jackdaniel has the ambition to keep it up to date.
4:07:35
beach
It is very active. I guess we can check with jackdaniel when he comes around. He probably spends the weekends with his family.
4:08:20
asarch
no-defun-allowed, actually the data is small posts from a Facebook account like: https://pastebin.com/SHtrRUpM
4:23:39
beach
asarch: Because of the differences in semantics between Common Lisp and the foreign language, it is always going to be difficult to manage a combination of the two.
4:23:52
no-defun-allowed
There aren't really good and evil in programming, but debugging C is much more annoying than debugging Lisp.
4:23:56
beach
asarch: Typically, the foreign language does not have automatic memory management, for instance.
4:25:17
beach
asarch: And think about debugging? If you use something like GDB, adapted to the foreign code, you won't understand what is going on when your code is executing in Common Lisp. Conversely, even if you have a fantastic Common Lisp debugger, it won't be able to inform you what is happening when code in the foreign language is executed.
4:26:56
asarch
I also wrote a web application using Caveman2 for the same cluster and some times when I refresh the list of the notes I get those messages
4:28:30
asarch
Those annotations are like this: 彼女はいつも新聞を読みます。 kanojo wa itsumo shinbun o yomimasu She always reads the newspaper.
4:29:32
no-defun-allowed
I think this happens when the web browser drops a connection when Hunchentoot didn't expect it. Though Hunchentoot usually logs it and carries on - does Caveman2 change that behaviour?
4:31:59
saturn2
if you call (hunchentoot:send-headers) to send the response directly to the output stream, you have to catch any stream errors yourself otherwise they will invoke the debugger
7:34:49
moon-child
writing a lisp, haven't implemented ,@ yet. I hadn't ever thought of doing this before (no call for it), but you can replace `(a b ,@c) with `(a b . ,c)
7:35:10
moon-child
(though of course, if the thing being spliced is in the middle of the list, there's no recourse)
7:39:17
moon-child
heh, no. Cl is large enough that most of my time would probably be spent reimplementing utility functions and macros rather than doing anything interesting
7:42:56
moon-child
I have been writing a list processing programming language, and in it I haven't...
7:44:38
beach
In Common Lisp, that construct is handled by a reader macro generating some special form.
7:45:26
beach
Er, let's not call it a "special form". Some data structure not intended for evaluation.
7:47:55
beach
Let me just say this: Given the number of libraries we have already created, and the ones that will exist soon, it should be much easier than it used to be to create a Common Lisp implementation, if that's what you want to do.
8:00:09
moon-child
SICL is a really great project. I think I might also have slightly different goals from cl with this project. Not entirely sure yet
8:00:52
Nilby
I must have forgot. Is there some way to turn a list into a function without eval, compile, or macro around defun?
8:01:43
Nilby
Like I want to turn l2 into a function: (let* ((l1 '(+ 2 3)) (l2 `(lambda () ,l1))) l2))
8:03:13
Nilby
no-defun-allowed: Hmmm. I guess compile and eval seem heavy for a tiny anonymous function.
8:04:10
no-defun-allowed
In this specific case, you could make it (let ((closure (lambda () (+ 2 3)))) (lambda () (funcall closure))).
8:05:33
no-defun-allowed
Using a chain of closures works well enough most of the time. (For example, CL-PPCRE uses a chain of closures to basically produce a non-deterministic machine which finds matches.)
8:08:46
Nilby
I guess I'm thinking of some old days where it just stored the lambda list as the function binding.
8:10:36
Nilby
Tangentially related, I was surprised by sbcl telling me this: "Objects of type COMPILED-FUNCTION can't be dumped into fasl files."
8:10:48
saturn2
that's pretty much what sbcl will do if you set sb-ext:*evaluator-mode* to :interpret
8:12:05
Nilby
saturn2: That's what I was thinking I guess, but if I do that then I'm in non-portable land.
8:16:27
no-defun-allowed
Really, if the forms you generate are similar enough, just use a chain of closures. If not, then compiling wouldn't hurt.
9:02:25
lukego
Hey how do you normally do a (list-of FOO) type? is there anything like that in e.g. alexandria or serapeum that's standard and idiomaic?
9:04:24
beach
He defines something called a "regular type expression", or RTE, that can express that kind of stuff. But it uses SATISFIES, obviously.
9:04:40
lukego
I will, but to be clear I mostly want to write (list-of FOO) in the source code for clarity, I don't mind if the impl would be e.g. with SATISFIES or just (deftype list-of (x) 'list)
9:07:05
lukego
that library looks very interesting (https://github.com/jimka2001/regular-type-expression) but looks like it's excluded from quicklisp due to build problems? https://common-lisp.net/project/cl-test-grid/library/regular-type-expression.html
9:07:37
lukego
yeah. I'll probably use SATISFIES although I understand that people generally resist this so wondered if there was another popular formulation
9:29:47
lukego
but for now I've written (deftype list-of (x) (declare (ignore x)) 'list) and this is ample for current purposes i.e. to avoid losing information while transcribing from an EBNF grammar into lisp structs.
9:30:34
lukego
I also added a similar (nyi-of X) that translates into T but captures that I need to define a proper X type later.
9:48:30
lukego
(I'm trying to transcribe an EBNF grammar for LLVM IR into Lisp structures - with serapeum DEFUNION - and trying on the one hand to only do the few bits I'm interested in right now while on the other hand keeping track in a disciplined way of what I'm skipping using information-preserving stubs.)
9:54:09
phoe
the main issue with gensyms is that it's impossible to preserve their identity across FASL-dumping