libera/#commonlisp - IRC Chatlog
Search
5:45:05
jeosol
I think I may have memory leak in my long running application that seems to cause it to crash/restart the machine. I want to capture the output of (room) as the application is running (e.g., after each iteration) so I can create a time series for the different categories of space usage when (room) is called. is this reasonable?
5:56:42
pjb
jeosol: yes. The verbose output of ROOM is written on *standard-output* so you may want to redirect it to collect it in a single file. Unfortunately, the result is implementation dependent, so you cannot count on it to be meaningful.
5:58:12
jeosol
pjb: you are so right. I was using with-output-to-string, get the string, process it. Unfortunately, the output is ordered in decreasing order of the usage. My initial implementation was processing the parsed string line by line, and reading of the usage.
5:59:02
pjb
jeosol: that's a good idea, since you can then #+ the implementation of this parsing depending on the implementation, to return always the same value(s).
5:59:10
jeosol
pjb: Of course this is not robust and a particular category may be on a different line due to the usage for that category since (room) for sbcl the output are sorted in decreasing order of the usage. So I may have to resort to some regex or esrap
6:01:45
jeosol
The code base is large and I think implementing this usage time series will at least give me some idea of where to look at. When I started coding, I was just creating arrays on the fly and I wasn't being very discipline. For my design, I elected to use variables to hold all computations for my runs. So when the runs are done, no further
6:02:58
jeosol
Of course, this requires having a lot more variables. Another option, is write intermediate results to files, after the runs are done, have another code post-process the intermediate files and generate other statistics. I am thinking this latter option should have been the better one.
10:14:37
splittist
Is there a proper way for referring to 'resetting' a closed stream? Obviously not all streams can be reset, but where one can, is there a good way to refer to doing this? Or would such a thing deeply undermine the nature of streaminess?
10:20:56
jackdaniel
resetting the stream-file-position is the closest thing, but it is not after the stream is closed
10:55:09
scymtym
you probably would have to "manually" ensure that there is no unread character in the stream. the way i read the UNREAD-CHAR and FILE-POSITION entries, unread characters remain "queued" after seeking
13:28:15
beach
Th ANSI test suite for MAPCAR contains a test with the form (MAPCAR #'APPEND) and the test expects a condition of type PROGRAM-ERROR to be signaled. But it seems to me that this test does not test the implementation of the function MAPCAR, but of the compiler. No?
13:30:45
semz
Maybe there used to be old implementations where the first list argument to mapcar wasn't mandatory
13:30:54
beach
Put differently, is the code for MAPCAR expected to signal a PROGRAM-ERROR when no lists are given? I would think not since PROGRAM-ERROR is about incorrect program syntax, and the form that invoked MAPCAR this way could be something like (FUNCALL SOME-FUNCTION #'APPEND) and there is no syntax error there.
13:33:08
masinter
what you want is a common language -- you can write a spec, you can write a test suite, you can build implementations
13:34:52
semz
beach: I mean that there may have been lisps (meanwhile absorbed by CL) where (mapcar #'append) was not an error, and that's why this test exists and is in the mapcar suite.
13:35:48
masinter
the test suite often leads when it shouldn't. if there were a cleanup issue i would vote for RETURN NIL option
13:39:39
beach
AHA, but that means I can't define MAPCAR the way I did. I did (defun mapcar (function &rest lists) and for a program error to be signaled, I must define it as (defun mapcar (function list &rest more-lists)
13:41:03
beach
semz: So since my definition has a single required parameter, PROGRAM-ERROR should not be signaled.
13:42:23
beach
I think it is allowed, and I think the test suite should not expect a PROGRAM-ERROR because the test suite can't know how the implementation wrote the lambda list.
13:44:25
specbot
Requiring Non-Null Rest Parameters in the ``Syntax'' Section: http://www.lispworks.com/reference/HyperSpec/Body/01_ddtc.htm
13:46:18
_death
I think this means that if you use "function &rest lists" you need to check for non-null lists yourself and (probably) signal a program-error
13:48:07
beach
I see PROGRAM-ERROR as something that the compiler detects, and not the implementation of a standard function.
13:51:03
gilberth
Depends on whether you say e.g. (defun mapcar (f &rest lists) ...) or (defun mapcar (f list &rest more) ...). In the former, I expect that the implementation of MAPCAR signals that PROGRAM-ERROR. Consider the argument list parsing your Lisp implementation provides as a convenience :-)
13:52:46
beach
gilberth: That's pretty much what _death says as well. However, the page referred to seems to strongly advise against the latter case.
13:53:56
_death
beach: why? the spec just needs this trick so that it's easy to describe the semantics of rest arguments as a whole
13:56:03
_death
from my memory (and again, I don't have any lisp manuals with me right now) previous lisps had mapcar take two arguments and I think CL extended it so that it could take more
13:56:03
gilberth
Begins with there is no standard function to ask for the lambda-list of a function. So even something like (defun cons (&rest args) ...) would be fine as long as that implementation of CONS would check the argument list on its own. To me it doesn't matter whether the implementation of a function uses builtin lambda-list parsing or rolls its own.
13:57:24
gilberth
And? This function can always punt. And what do you expect it gives for MAPCAR. CL doesn't know about this &rest args+ notation.
14:04:00
gilberth
masinter: Not only Interlisp. Standard Lisp is that way around as well. But then you cannot pass more than one list to travel along.
14:06:23
_death
gilberth: but then you can extend it to (list &rest functions+) and apply the composed function to each item
14:07:46
gilberth
Like (mapcar (mapcar list f1) f2) = (mapcar list f1 f2)? Oh, that never occurred to me.
15:55:39
ogamita
You're close to the functional programming proposed by Backus in his famous paper. Implement a set of utility functions to be able to write your functions without using variables, just by composing other functions. Basically (setf (fdefinition my-new-function) (some (composition (of (other functions) f2) f3) f4))
15:56:51
ogamita
ie, stop using funcall. Use: (fset myfun (partial (compose funcall over) f1 f2 f3)) (myfun l1 l2 l3)