freenode/#lisp - IRC Chatlog
Search
21:11:56
mfiano
That depends how you want to represent bytes. Implementations are also free of this choice.
21:16:49
emaczen`
What is the easiest way to write bytes to a stream just using standard commonlisp?
21:21:28
emaczen`
I want to write, a length, width, and height, and then from a sequence of bytes from a C array all to a stream
21:27:02
Bike
the manual says accept-connection inherits properties of the socket you give it, os there's that
22:03:53
fe[nl]ix
Bike: see https://wiki.creativecommons.org/wiki/CC0_FAQ#May_I_apply_CC0_to_computer_software.3F_If_so.2C_is_there_a_recommended_implementation.3F
22:08:11
Bike
what happened is that i found the basic approach inadequate. it can't fully leverage type inference and other information because that just doesn't exist at source level, and there aren't any portable hooks into intermediate representations
22:09:20
Bike
which doesn't directly answer your question. but working on a compiler like i do now, i do think having a bunch of different optimizations you can try is important
22:36:43
jmercouris
Hey everyone, I'm having a weird issue with my quicklisp loading of a system I've defined, it worked when I started lisp last, but doesn't work this time: https://gist.github.com/15a2777be6681df08f2d5a345314764d
22:37:14
jmercouris
I get: System "next" not found [Condition of type QUICKLISP-CLIENT:SYSTEM-NOT-FOUND]
22:38:20
Xach
jmercouris: (ql:quickload <anything>) necessarily involves a call to (asdf:load-system <anything>)
22:39:18
jmercouris
Bike: I've pushed the system the line before though, can the slime repl maybe have the wrong directory? within the "push" function?
22:40:06
Bike
i've never been quite sure what the "current directory" is to lisp. default pathname defaults, i guess
22:41:11
rpg
agree with Bike -- you should always avoid using relative paths in your asdf configuration. CL does not have a notion of "current directory" -- the relationship between the OS notion of CWD and the CL notion of default-pathname-defaults is implementation-dependent and fraught with unpredictability
22:41:55
jmercouris
rpg: Different people will then have to configure the run script for their machines
22:42:09
rpg
Between LOAD-TRUENAME, COMPILE-FILENAME and ASDF:SYSTEM-RELATIVE-PATHNAME, you should be able to avoid both relative pathnames and special configurations.
22:42:12
emaczen`
Bike: I'm looking at the CCL doc, and it says that sock-streams always are bivalent
22:42:44
rpg
Or you can stuff the next system inside your quicklisp/local-projects, and then I think you can quickload everything
22:42:57
Bike
emaczen`: bivalent means it can be read from or written to, it's unrelated to signedness.
22:46:31
rpg
jmercouris: You can also have the script load an ASDF configuration form, that is relative (uses :HERE)
22:46:33
jmercouris
Bike: hmm, changing to an absolute path fixed it, now time to do some of the magic with those paths
22:47:21
rpg
ACTION can't look up the manual right now--frantically trying to finish a paper by the deadline this evening...
22:48:58
jmercouris
rpg: https://common-lisp.net/project/asdf/asdf.html#The-here-directive I found it
22:49:09
jmercouris
while useful, I don't think I will pursue that avenue, I'll do things the Bike way
22:49:32
rpg
yup. That DSL description can be used together with (asdf:configure-source-repository ...) [might have the precise name wrong]
22:55:44
jmercouris
Bike: Do you know of a way to get the *load-pathname* without the merged filename at the end?
23:00:05
rpg
jmercouris: pathnames in CL are a nightmare -- there's no consistency in how different implementations deal with the notion of a pathname that points to a directory, because the spec doesn't have that notion (it was designed to cover also filesystems where directories weren't files...)
23:00:57
Josh_2
There is UIOP (I believe) however it's directory function doesn't work properly on ECL
23:01:55
sebboh
hi all. What is a common way to get the fractional or decimal part of a number? For example, 12.8 ==> 0.8 ?
23:02:26
pjb
Of course, for pathnames designating POSIX files on a system lacking support for anything else, it may not make a difference, but 1- if your *load-pathname* is a logical pathname you're hosed, 2- if your implementation runs on java where they shoehorn urls into physical pathnames you're hosed.
23:02:27
Josh_2
Well all the code worked on SBCL, then when I tried ECL as I wanted a small binary it failed because the function directory wouldn't work with the directory pathnames it was being given..
23:02:48
sebboh
I guess I only need it for positive numbers, but I'm curious about how to get -0.8 out of -12.8, too...
23:04:01
pjb
Mostly, people have problems with pathnames in CL, because they don't understand it, and try to take shortcuts like directory-namestring, just because they can't imagine a file system different from what they use everyday.
23:04:20
jmercouris
pjb: I actually literally cannot imagine how else to structure a file system than a unix tree
23:04:56
Josh_2
I spent a lot of time on pathnames not long ago, so I have a better understanding than I did
23:05:34
rpg
jmercouris: Yes, there was more diversity in operating systems when the ANSI CL spec was written. But it doesn't constrain implementations enough to make things consistent. TBH, you are better off mostly using Fare's code.
23:05:44
pjb
jmercouris: https://www.mjt.me.uk/posts/falsehoods-programmers-believe-about-addresses/ http://www.creativedeletion.com/2015/01/28/falsehoods-programmers-date-time-zones.html https://en.wikipedia.org/wiki/Time_in_Antarctica http://www.kalzumeus.com/2010/06/17/falsehoods-programmers-believe-about-names/ etc https://github.com/kdeldycke/awesome-falsehood
23:06:43
jmercouris
pjb: Great links, I've seen some of those, and I weep for people who have to implement datetime classes
23:07:41
pjb
Users will tell you a French SS number starts with 1 or 2 indicating Male or Female. Wrong. French SSN can start with other digits indicating other Sex statuses (like unknown, temporary SS number, etc).
23:08:26
pjb
As programmers you have to generalize, taking into account all the "exceptions", which are just cases like the normal cases.
23:12:14
pjb
(loop for (n d) in '((10 3) (1 0)) collect (handler-case (truncate n d) (:no-error (q r) (list :quotient q :remainder r)) (error (err) (princ err) '()))) #| division-by-zero detected, performing / on (1 0) --> ((:quotient 3 :remainder 1) nil) |#
23:14:11
Josh_2
I knew not all conditions are errors, and that's a neat way to use that functionality
23:28:41
emaczen`
How do I write integers into a CCL socket and read the same integer on the other side?
23:29:12
emaczen`
I don't see anything in the CCL documentation where you specify the "stream-type" like you do with regular io
23:30:15
Josh_2
Are you sure you sent it because I believe you have to use something like (terpri <ur stream>) to make sure it is sent
23:30:37
sebboh
(* 60 (mod foo 1)) happens to give something like 20.000038. It's a number of minutes, so "20" would be fine. I tried a format string like ~2D but still got 20.000038 ... then I tried ~2F and got "20." ... which I didn't expect. lil help? :)
23:50:01
pjb
emaczen`: this is assuming a character stream. If you have a binary stream, you can either transmit the string, or if you want to transmit the bits, youc an use integer-length and ldb and dpb on the receiving side. You will have to encode integer-length the same too (it could be bigger than 256…)
23:53:38
emaczen`
pjb: Well the read side should be fine since I am really just trying to replace my server side ABCL code with CCL
23:59:05
emaczen`
(write-sequence (make-array 3 :element-type '(signed-byte 32) :initial-contents (list length width height)) connection)
0:00:08
pjb
You would have to use a :element-type '(signed-byte 32) so it would work only if the same implementation is at both end, same version, on same platform. Perhaps.
0:04:03
emaczen`
pjb: Can you give me a short example with ldb, with just writing the 4 byte integer 480 to a stream?
0:05:17
pjb
(write-sequence (vector (ldb (byte 8 24) n) (ldb (byte 8 16) n) (ldb (byte 8 8) n) (ldb (byte 8 0) n)) socket)
0:06:23
pjb
and (progn (assert (= 4 (read-sequence v)) (dpb (aref v 0) (byte 8 24) (dpb (aref v 1) (byte 8 16) (dpb (aref v 2) (byte 8 8) (aref v 3))))))
0:13:21
pjb
Sure you can; first convert your integers to bit vectors: (write-sequence (make-array (integer-length n) :element 'bit :initial-contents (loop for i below (integer-length n) collect (if (logbitp i n) 1 0))))
0:13:23
emaczen`
Ill have to read about ldb again -- mfiano took me through it a litle, but I didn't even know that bytes weren't constrained to 8 bits
0:14:10
pjb
but for that you need to use :external-type 'bit and it is implementation, platform and target dependent how bits are transmitted and received. No guarantee! Or if you still use :external-type '(unsigned-byte 8) then you transmit one octet for each bit! 8 time the transfer size!
0:16:52
emaczen`
I think bit-vectors are more expressive than ldb -- but if there are lots of issues I guess I'm back to reading ldb...
0:25:20
lambdice
what do you think about this book ? https://www.amazon.com/Common-Lisp-Recipes-Problem-Solution-Approach-ebook/dp/B01JFTONBS/ref=mt_kindle?_encoding=UTF8&me=
4:23:43
SaganMan
Xach: I bought the Winston and Horn 3rd edition book cheaply from amazon. The book cost is 2$ but shipping to my country is 3$.
4:23:43
minion
SaganMan, memo from pjb: Books are heavy, that's why we invented electronic books. Have it scanned!
4:39:09
pjb
lisp was discovered in 1958, first implemented in 1959. C was designed in 1969, evolved from B and BPCL.
4:40:09
aeth
Languages are living. Early lisp is ALL-CAPS and full of goto. Early C looks totally different, too.
4:40:45
aeth
Lisp predates C but the Lisp you'd read in any random program has a very late-1980s feel to it, if not later.
4:42:55
pjb
There was GO (used in PROG) in LISP 1.5, but most functions were written in quite a functional style.
4:43:35
aeth
But I guess my point is that modern Lisp is heavily influenced by Scheme (1970) and Smalltalk (1972)
4:45:10
aeth
pjb: What's the one that's full of GO? I remember reading one, and you seem to know all the popular really ancient Lisp programs
4:46:30
pjb
I don't know. I was about to say that it would be interesting to collect old programs, and do some statistics…
4:48:38
aeth
I think it used prog. http://www.lispworks.com/documentation/HyperSpec/Body/m_prog_.htm
5:02:16
pjb
SaganMan: yes and no. It's not written directly by human programmers, but it's expanded by macros.
5:28:22
aeth
I prefer physical books because it's easier to focus reading a physical book than a book on a distraction device.
5:32:42
whoman
kindle apparently has nice screens for reading. i turn brightness down on mobiles which probably helps in one way but hurts in another