freenode/#lisp - IRC Chatlog
Search
10:57:48
Posterdati
please II need to pretty print an object into a string without line feed or return inside the result. I used (format nil ...) but it adds #\Newline in the string
11:13:13
_death
fouric: like you want to use an fd-stream, which allows control of buffering, for that
12:19:50
michipili
Hi @Xach, @rumbler31 and all that helped me yesterday! Unfortunately I have been banned by the server because of posting error logs, which was recognised as a flood. :)
12:54:02
michipili
Admins at chat.freenode.net encouraged me to use pastebin for error logs. I also could solve the issue by adding the following to my ~/.sbclrc
12:54:49
michipili
(load "~/quicklisp/setup.lisp") (ql:quickload :cffi) (pushnew #P"/opt/local/lib/" cffi:*foreign-library-directories* :test #'equal)
14:40:12
shrdlu68
Why does this with-output-to-string return an empty string? http://paste.lisp.org/display/356394
14:50:31
didi
Bike, beach: Sorry, I was AFK. So you wouldn't use `defsetf'? And sorry, but what do you mean by "define the setf function yourself"?
14:52:01
shrdlu68
I see, the length is indeed non-zero. But what's going on here? How is the ansi escape code preventing the value from printing properly?
14:56:17
shrdlu68
Oh, the output is a complete ansi code, so when it's printed it get's "interpreted" by the terminal emulator.
15:12:38
didi
(defun (setf ...) ...) worked like a charm. Now, is it possible to `setf' multiple values to the same place?
15:16:03
didi
Say I want to store A, B, and C in the place P. I could call (setf P (list A B C)), but the receiving end wouldn't know if it is a single value (a list) or 3 values (A, B, and C).
15:56:36
didi
Thank you all. One more: Can I write an elaborate `incf'? I have an CLOSS object that has a complex structure, but it makes sense to (incf obj) it.
15:57:15
pjb
didi: Bike: ok, so the problem is that you can accept a pre-determined number of multiple value, but there's no way to know (exactly) how many values you will be given! It's implementation dependent how setf is implemented and how it stores the multiple value. eg. in ccl, it (setf (mv x) (values 1 2 3)) will expand to a (multiple-value-bind (…) (values 1 2 3) …) so you cannot know how many values there are. You can only fil
15:57:15
pjb
trailing NILs, but this could reduce the number of values (values 1 2 nil nil) are 4 values.
16:05:37
|3b|
ACTION would expect INCF to break on the + part rather than the SETF part for arbitrary objects :)
16:12:01
Josh_2
Is there a Lisp alternative to uint_8 from C? I can make my own but I haven't written any lisp in a while so I'm struggling to remember anything
16:18:04
Josh_2
Okay, so I've got this C++, and I'm wondering if there is something with similar functionality already available. Where I don't have to set each value manually.
16:19:16
pjb
(let ((width 330)) (make-array 3 :initial-content (list 0 2 width))) #| ERROR: Incorrect keyword arguments in (:initial-content (0 2 330)) . |#
16:19:22
pjb
(let ((width 330)) (make-array 3 :initial-contents (list 0 2 width))) #| --> #(0 2 330) |#
16:29:41
beach
Can (LOCALLY declaration* form*) always be replaced with (LET () declaration* form*)?
16:32:11
_death
(let ((a 42)) (locally (declare (type integer a)) ...)) ; here (let () (declare (type integer a)) ...) is bad
16:35:16
beach
didi: The question is what happens when the variable in the declaration is free in the form.
16:42:21
pjb
locally says: Sequentially evaluates a body of forms in a lexical environment where the given declarations have effect.
16:43:52
specbot
Processing of Top Level Forms: http://www.lispworks.com/reference/HyperSpec/Body/03_bca.htm
16:44:29
pjb
beach: indeed. That seems to be the only difference. With respect to declarations themselves, it's the same.
16:45:08
dlowe
the magit dev made his kickstarter goal. i wonder if this is a sustainable way to make a living.
16:45:18
kenanb
is there a format directive or a compound one that can justify (monospaced) text in typographical manner?
16:47:35
dlowe
I have a *lot* of monospace text formatting stuff that I made for my MUD. I should package it up into a library
16:47:36
kenanb
dlowe: yeah, I think I need to do way more than some math to make ~t justify like that :D
16:48:26
dlowe
kenanb: you might like this, though: https://github.com/TempusMUD/cl-tempus/blob/master/src/support/editor.lisp#L157
16:50:04
kenanb
dlowe: hmm, that is cool, yet I guess I will still need to implement it myself, this is standard word wrapping, doesn't actually do the stretching.
16:50:05
pjb
beach: My opinion is that if they had took the pain of writing some formal semantics, they would probably have unified those semantics. For example,e clhs let repeats that the body is in an implicit progn, but this leaves out the declarations. It's not too explicit on the scope of the declarations… Formally, they could have used bindings+locally and then (let () …) could have been equivalent to locally. (unless the wanted to
16:52:44
kenanb
dlowe: yeah, I kinda agree. I once thought I might come up with a better full justification algorithm, I guess I will try that now.
16:53:19
dlowe
If you want it to look really nice, you'd be better off implementing Knuth's word wrap that he uses for TeX
16:53:58
dlowe
full justification is just accumulating fractional error and inserting spaces at integer bounds.
16:54:07
kenanb
dlowe: you know, that is indeed a good idea, I am a huge sucker for TeX output. (not the TeX language tho)
16:54:31
pjb
In the differences between LET and LAMBDA: (let ((a 42)) "foo" (declare (type integer a))) is an error; ((lambda (a) "foo" (declare (type integer a))) 42) returns nil.
16:59:07
pjb
And trying (disassemble (compile nil '(lambda () (let ((a 42)) (let () (declare (type fixnum a)) (the fixnum (truncate a 2))))))) in ccl and sbcl shows that the declaration is correctly taken into account.
17:02:16
pjb
Now, since we're already inside a LET, (let (locally)) and (let (let ())) will be strictly equivalent, since there's no toplevelness there.
17:05:53
Josh_2
Just figured out that (write-byte ..) literally writes the integer as an entire byte, I actually do feel stupid now.
17:09:05
pjb
(with-open-file (out "/tmp/21-bit-bytes.bin" :direction :output :if-does-not-exist :create :element-type '(unsigned-byte 21)) (write-sequence (map 'vector 'char-code "Здра́вствуйте!") out)) #| --> #(1047 1076 1088 1072 769 1074 1089 1090 1074 1091 1081 1090 1077 33) |# ; (uiop:run-program "od -t x1 /tmp/21-bit-bytes.bin")
17:12:06
pjb
Josh_2: now, assuming 8-bit-byte-based POSIX file-system, and assuming reasonable CL implementations, and assuming you use (unsigned-byte 8), it is expected that you can write files that can be read back by different implementations on the same 8-bit-byte-based POSIX file-system.
17:12:58
pjb
Josh_2: We can even expect being able to transfer those files to other POSIX systems wiht 8-bit-byte-based POSIX file-systems, and be able to read them back using reasonable CL implementations, and assuming you use (unsigned-byte 8).
17:13:55
pjb
But that's really the most we hope for. Don't try signed-byte, don't try other byte sizes. Don't try other systems (certainly not 36-bit-word-based systems, they often use 6-bit or 9-bit bytes…).
17:16:07
pjb
The only problem with clisp is when your byte size is not a multiple of 8, it needs a header to indicate how many bits are used in the last octet.
17:16:53
pjb
But the advantage is that if you have to write small bytes (1 to 7 bits), it gives smaller files. You can read and write files bit by bit :-)
17:17:27
_death
beach, Bike: ok, after reading http://www.lispworks.com/documentation/HyperSpec/Issues/iss096_w.htm (which also says the LEXICAL proposal passed), I now believe that such declarations are ordinary "free declarations" and are allowed
17:18:24
pjb
Josh_2: well, clisp ensures it can read its files on all the platforms it runs on. So notably it always write binary files in little-endian, so you can exchange them between MS-Windows and Linux or Darwin.
17:19:52
pjb
Well, I assume you could design a custom declaration where its semantics would be different in let let than in let locally…
17:21:00
pjb
Basically, a declaration applies on the whole form. So if the whole form is different, the declaration may apply differently.
17:30:14
jmercouris
hey everyone, I just wanted to say, thank you for the support you've given me these past few months
17:30:35
jmercouris
with that I've released v0.02 of nEXT, which I've posted about it in the lisp subreddit: https://www.reddit.com/r/lisp/comments/71kpzu/next_browser_ver_002/
17:57:11
jmercouris
jasom: I thought it would be too much work to make the chrome as well as the rendering engine
17:57:38
jasom
ACTION didn't know QT had a webview; I assume it uses the OS'es native webview on mobile?
17:59:07
jmercouris
jasom: I'm not sure what it does on mobile, but nEXT is designed for OS X, Linux, and Windows, mobile support is kind of out the door because it relies on the keyboard
18:12:08
cgay
Hi folks. Anyone know the status of EuLisp these days? Any active work on it? Use of it? For some reason I never really took notice of it before but it looks very appealing.
18:15:28
dlowe
The topic of #lisp is Common Lisp, while ##lisp is for discussion of the lisp family as a whole.
18:18:03
cgay
But it looks so similar to Dylan (from a glance at the wikipedia entry) that I'm shocked I never looked at it before.
18:21:50
cgay
Probably silly to have even asked, given "There is an FTPable copy [of the spec] available [in .ps and .dvi]"
18:49:17
jasom
Xach: is that the one where someone from the US intentionally started bikesheding on the name?
19:05:52
shka_
any reason why alexandria:emptyp is defined only for sequences and not for hash table?
19:11:30
francogrex
(setf (test-age *test-inst*) "aavc") is acceptable and make-array gives elements 0 ?
19:12:30
shka_
dlowe: that misses the point, i wanted to write library that integrates nicely with the rest of the world
19:12:57
mfiano
type declarations in Common Lisp are not enforced...they are merely a suggestion to the compiler.
19:13:46
dlowe
shka_: name it empty-hash-table-p or send a change to alexandria to have it changed to a method. Or send a change to alexandria to add hash table support.
19:15:30
mfiano
You would have to loop over the array. It is unclear exactly what you expect that code to do though.
19:16:53
_death
shka: it's unlikely to be incorporated.. alexandria is meant to be conservative, and I never saw an emptyp function that cares about hash-tables
19:17:16
_death
shka: nor do I remember the last time I needed to know if a hash-table is empty or not..
19:19:56
mfiano
common lisp has hash-table-count too i believe, but i don't think i've used this more than a handful in a decade of use
19:23:10
francogrex
let's try this for illustration: (let ((array (make-array 3 :element-type 'testclass))) (setf (aref array 0) *TEST-INST*))
19:23:14
shka_
in fact i would say that majority of languages actually have some sort of check if this thing is empty function
19:26:46
Fare
beach: are you here? vyzo & I would like to add features to Gerbil's object system, hopefully getting it on par with CLOS (though maybe with C3 linearization by default).
19:31:32
shka_
interface passing style is very useful when implementing data structures (very nice way to separate abstract and concrete data types) but I consider it to be cumbersome for library user
19:32:44
shka_
so although i am doing lil-like stuff under the hood, actual API is rather conventional object oriented code
19:35:36
shka_
Fare: on the other hand, i am really glad that I read your blog post describing lil, it was deeply enlightening
19:37:20
Fare
so you can *define* your library using the full power of interface-passing style, yet expose a monomorphic and/or OO interface to your users.
19:38:37
Fare
this can be useful when bootstrapping more elaborate data structures from simpler ones
19:39:11
emaczen
I'm looping, creating arrays of size 1024 and then writing these arrays to a file with #'map and #'write-char. Most of the time my file sizes are multiples of 1024 -- why would a few files not be multiples of 1024?
19:40:31
emaczen
Fare: How do I ensure UTF-8 -- I was thinking it could be a potential character-encoding issue?
19:41:28
Fare
emaczen, I don't know what you're trying to do, but uiop and asdf-encodings give you portable ways to deal with file encodings
19:41:50
shka_
needless to say, I understand motivation behind lil design after fighting similar problems
19:42:36
Fare
the next step after lil would be a linear lisp, in which all the data structure styles would be actually isomorphic at the language level.
19:43:30
Fare
shka: you should see the amazing things that ekmett does with type classes. You could do the same with lil.
20:02:52
francogrex
Bike: even with SBCL 1.3.21 i still get the style warn error :( but also maybe my build was not great: http://paste.lisp.org/display/356473
20:04:26
shka_
my implementation is a little bit niche because it allows for transactional style insert, and therefore lazy implementation can minimize consing due to copy-on write
20:05:36
Fare
not sure what exactly you mean, but yes, that's what tries are vs AVL, they have more "canonical" forms so allow for more sharing.
20:14:33
shka_
Fare: anyway, whole trick with HAMT is to store fixed (32 for instance) number of children in each node, each representing part of the hash (5 bits in the example), then adding 32 bit mask with 1 bits on positions that actually hold children
20:15:31
shka_
this way you can use combination of logcount and ldb to map hash onto into positions in vector
20:16:29
shka_
it is pretty nice because it is simple, hash can be as long as you want, it does not take whole lot of space, does not need rehashing, can be made unmutable and stuff
20:21:38
jasom
shka_: that implementation does use the lowest-order bit of the pointer for tagging, but is otherwise pretty straightforward
20:27:27
jasom
shka_: I did an implementation way back; ~2x slower than sbcl's eql hash tables for integers and ~3x for #'equal hash-tables for strings
20:31:01
jasom
ugh, 50x slower on ccl versus ccl builtin. Probably because of all the bitwise operations
20:33:46
jasom
ah ,strings are only 4x sloer than hash-tables it's purely fixnums that my critbit tree loses so badly on
20:36:53
jasom
oops, I'm actually more than 2x slower; I didn't run the benchmark code by itself for subtraction
20:37:03
jasom
shka_: https://gist.github.com/anonymous/ebcea5207209e1ef3678d7a3ef279ad0 for when you are interested
20:41:13
dim
Xach: what's the deal with rename-file? I usually use (uiop:make-pathname* :name "bar" :type nil :defaults foo), is that possible for you?
20:41:56
shka_
because of cl-ds:position-modification insanity popped up, and this REALLY need explanation
20:42:12
Xach
dim: the deal is that i don't think there is a way to make a pathname target that does not take the pathname-type of its source on clisp.
20:42:42
Xach
dim: on other implementations, it is done with :unspecific, meaning "no type and don't merge into it", on some implementations.
20:47:15
Xach
dim: CLISP has many other behaviors that are permitted but annoying. (In different, more annoying ways than, say, SBCL)
20:50:36
Xach
dim: Oh, trying to make a ported function that can rename "foo.txt" to "bar". That meant testing, and when I got to CLISP, this came up.
20:51:28
pjb
It is an error to specify a filename containing a wild component, for filespec to contain a nil component where the file system does not permit a nil component, or for the result of defaulting missing components of new-name from filespec to contain a nil component where the file system does not permit a nil component.
20:51:30
Xach
I never knew that :unspecific was not broadly supported, so it made me wonder if there was an alternative on CLISP.
20:51:40
dim
ACTION .oO(who bets pjb has an AGPL or GPLv3 lib with a portable rename-file that handle that case even in CLISP)
20:52:09
pjb
You'd lose. For pathnames I tried to make implementation work the same on the same platform.
20:52:51
Xach
It's also become a little academic - I'm not looking for "how to do this on clisp by any means necessary" but "am i missing something in clisp that would make rename-file work the way i wish"
20:55:52
jasom
minion: memo for shka: an interesting data-structure (though not necessarily of practical use over 2,4 or red-black trees) is discussed here: http://user.it.uu.se/~arnea/abs/gb.html
20:57:47
pjb
Bike: to understand that you have to understand that clisp provides a uniform API on all its target systems, which include(s|ed) MS-DOS, MS-Windows, Amiga, etc, in addition to unix system. On MS-DOS all pathnames have a type!
20:59:12
pjb
But again, I see no real point in patching pathnames or file system primitives, until we agree on a way to deal with physical pathnames in a common way on the same target platforms.
21:00:08
emaczen
how do I "set" the file encoding? I'm writing 1024 byte blocks to a file and after each disk write I have ensured that the file-length is a multiple of 1024. I guess this means that linux has added some extra bytes to my file?
21:01:04
shrdlu68
ACTION Hmm, so setting a terminal in "raw' mode is something mediated by the OS, a syscall. I was hoping it was something that could be done through ANSI ecsape codes.
21:01:06
jasom
on a related node, is there a trivial-external-formats (or some such) for generating portable code that uses :external-format?
21:02:05
dim
jasom: have a look at https://github.com/dimitri/pgloader/blob/master/src/utils/charsets.lisp for some fun and an elaborated “I don't think so” answer
21:02:06
pjb
shrdlu68: or at least a terminal emulator. Eg. xterm can switch to tek terminals that are binary.
21:03:01
pjb
or com.informatimago.clext.character-sets and com.informatimago.common-lisp.cesarum.character-sets for a "portable" way.
21:05:47
shrdlu68
I was trying to do this without having to rely on curses, and using only lisp. Final barrier is that I can't get the terminal to switch modes, such as disabling local echo.
21:06:26
pjb
Well you can always re-implement curses in CL: just go parse and read terminfo or termcap, depending on what's available on your system…
21:06:56
pjb
Then of course, *terminal-io* is a character stream, so you'll need an implementation specific to open a binary stream on the same file descriptors…
21:07:59
dim
I guess I'll find a way to do graphics in CL, meanwhile we're doing https://docs.racket-lang.org/quick/ and it's pretty nice