freenode/#lisp - IRC Chatlog
Search
3:08:43
pjb
asarch: you have two ways of detecting it: returning a value, or signaling a end-of-file condition.
3:10:12
pjb
Note, you can always save the detection of eof into some hash-table and write a feof function to get it, if you want to reproduce the bugs of C…
3:10:37
pjb
asarch: alternatively, in the case of file-stream, you can test (= (file-position stream) (file-length stream)).
3:17:20
pjb
asarch: but similarly after this test of file-length, it may change, so if the test is false, it doesn't mean you will be able to read anything. If it returns true, it doesn't mean you won't be able to read something.
4:01:27
pierpa
just tell him what he probably is looking for? asarch, probably you want: (loop for line = (read-line in nil nil) while line do ...)
4:11:57
pjb
asarch: so read-line returns usually a string, so returning NIL when eof is discriminating.
4:13:55
pierpa
right. Thanks pjb. I must correct myself: most input functions can either signal a condition or return a value you choose on end of file.
4:22:18
asarch
Question: if Common Lisp is not a multi-threating environment per se, why the "feof checks it too late, the file might have grown since!" condition?
4:25:11
pjb
This is because the OS and CL are different entities that you cannot know when the file will grow (or shrink).
4:26:00
asarch
pierpa, I just looking for something a la C: while (feof(fp) != NULL) {fscanf(fp, "%s", buffer); printf("%s", buffer);}
4:28:15
pjb
asarch: reproducing C bugs in CL will require more work; as I explained above, you can define a feof function, by memorizing the result of the last read operation for each stream!
4:31:11
pjb
Notice that C doesn't have multiple values, conditions, or types associated to objects. This is so defectuous! This is why the function fread() cannot distinguish between end-of-file and error! Hence the need to store the eof status in the stream record, and retrieve or clear it with feof and clearerr.
4:31:46
pjb
asarch: but this let you forget that those are not synchronous operations! You're just accessing a memorized flag in a structure.
4:34:35
pjb
asarch: for example, that you don't write a while(!feof(fp)) loop. You're a lame C programmer.
4:39:12
asarch
When I was learning JavaScript, I asked if there was a shell who could understand JavaScript commands directly
4:40:19
asarch
However, they told me that it was not possible because the common and useful shell constructs like piping and redirection would conflict with JavaScript constructs
4:58:18
pjb
asarch: cd ~/quicklisp/local-projects ; git clone https://gitlab.com/com-informatimago/com-informatimago.git # Then (ql:quickload :com.informatimago.common-lisp.cesarum)
4:59:29
pjb
(com.informatimago.common-lisp.interactive.interactive:lspack :com.informatimago.common-lisp.unix.passwd t)
6:42:02
jackdaniel
but looking at PRs it seems it is not *actively* maintained. but it is not abandoned either
8:59:07
phoe
I have a DEFINE-FOO macro that has a &body as its last argument. I need to tell it that the first string of that &body is a docstring and should be highlighted as such, not as an usual string.
9:10:19
dmiles
lets say my lisp reader is reader a symbol had just read.. "#:A" . Are these the only characters that will stop reading the symbol? #\; #\, #\( #\) #\' #\` #\" #\: ?
9:11:13
schweers
dmiles: if I understand your question correctly, every terminating macro character will terminate (hence the name) reading the symbol (or number)
9:12:48
schweers
they are listed somewhere in the hyperspec, I’m looking for the page right now, give me a sec
9:15:57
schweers
not quite as nice, but figure 2-7 does the job: http://www.lispworks.com/documentation/lw70/CLHS/Body/02_ad.htm
9:16:40
schweers
keep in mind that we are talking about standard syntax, you may change the readtable to include other terminating macro characters
9:19:33
dmiles
also next is there a lisp reader written in lisp somewhere.. the reader i implemented is too permissive .. for example I dont keep count of backquote level when reading commas
9:22:43
Shinmera
schweers: What do you mean? The reader is just an algorithm. You can implement it in any language.
9:23:35
schweers
Shinmera: I don’t know a lot about bootstrapping, but then I remembered that one needs a working CL environment to build sbcl, so it doesn’t seem that unusual anymore.
9:25:12
dmiles
i i was suprised at sbcl is that impls end up doing a minimalistic reader in their lnaugage (say C) then if they start to writ e alisp reader in Lisp.. their C code gets jealous and starts to take over until the lisp becomes busywork
9:27:33
dmiles
so they weight the cost benefits of having two codebases.. one lame one in C they cant delete (and they forever have to improve) .. vs a *overly* fantastic one im Lisp
10:24:21
dmiles
well my current reader is doing pretty well... it will probly be a week to two months before i really need to borrow a reader in lisp
11:05:57
beach
scymtym_: It looks like it is close to being usable. I certainly intend to start using it for reading SICL code.
11:29:30
scymtym_
beach: it should definitely be fine (strictly speaking "no worse than") for that particular case since it still mostly identical to the code it is replacing. i was referring to FIXMEs for not-yet-defined condition types, recently discovered (small) bugs and the like with that statement
11:56:55
beach
scymtym__: Sure, I understand that it is not completely finished, but it is definitely getting there.
12:43:50
pfdietz
dmiles: SBCL doesn't have to have a reader written in C, any more than a C compiler needs to have a lexer/parser written in assembler.
13:11:46
dmiles
pfdietz: to read SBCL's lisp reader into SBCL i was assuming there was a less functioning primordial reader
13:45:44
pfdietz
And gcc is written in C and compiled with a C compiler. The first C compiler written by Dennis Ritchie was in PDP-11 assembler though.
13:51:36
beach
It is very strange to me that so many people assume that a Common Lisp system must be (at least partially) written in some other language.
13:58:37
beach
makomo: So you are saying that, if asked, these people don't think that C compilers are written in C?
13:59:34
makomo
i always like to think about what would happen if you had the ability to destroy all compilers for high-level languages in an instant
14:00:02
makomo
the same would happen if you destroyed all of the robots in factories or something like that
14:00:51
makomo
it's a very interesting concept, because if you go deep enough, *someone* had to make the first version from something that was more primitive
14:09:26
JuanDaugherty
maybe with a core bootstrap in something else, e.g. the vm in smalltalk being in machine lang