freenode/#lisp - IRC Chatlog
Search
3:52:38
Zhivago
Above, you are printing one edge of that interval at some precision and assuming that it corresponds with the identity of the inteval, which is not true.
3:59:11
pierpa
try (decode-float 0.00002), (decode-float 0.00003), etc, then check references to understand what the results mean.
4:15:37
beach
fourroot: It is not that floating-point arithmetic is inexact. It isn't. At least not with IEEE floating point numbers. But, for a decimal fraction like the ones you give as examples, there is no exact binary floating point value for them, so you typically get the closest available one.
5:19:38
stacksmith
Your question makes no sense. '(+ 2 2) is a list. You could compile it, make a function, and run it - is that what you mean?
5:22:43
Digit
hi. (presumably) quick question, why does (- 9000 (* (round 9000 100) 99.99)) return 0.9003906, instead of just 0.9? ( same behaviour with s/round/floor|truncate|ceiling/ ) ~ poking around in ghci (which i'm similarly incompetent in), and i get the likes of "9000-8999.1" giving 0.8999999999996362. !? why's this madness not corrected? or is it correct, and i'm the one who's gone mad? srsly tho, there's a word for this, right? (to
5:23:59
stacksmith
floats don't always have an exact representation, so you get the nearest one. It is not a Lisp issue.
5:30:31
beach
It is interesting that people discover this problem only when they start using Common Lisp, having used floating point numbers with other languages for many years, without knowing how they work. This is very scary to me, because who knows how many professional developers have made software that is relied upon, but that is buggy?
5:33:02
beach
Most people never get to use Common Lisp, so they never discover the problem like this.
5:34:25
beach
My point is that people seem not to notice those problems with other languages, presumably because of the way those numbers are printed, with a limited precision.
5:35:19
beach
So, while, as I pointed out, the problems exists everywhere, it goes unnoticed even by professional developers using floating-point numbers in the software they write.
5:46:15
aeth
Other languages tend to default to double-float instead of single-float. The issues with floating point are more obvious in single-float.
5:49:24
aeth
(Combine that *with* rounding when printing, of course. The example still fails with double float, just more decimal points down.)
6:20:28
aeth
If you think in terms of counting cells: | 1 | 2 | 3 | 4 | 5 | (first, second, third, etc.), but if you think in terms of *offsets* from the start: | 0 | 1 | 2 | 3 | 4 | (i.e. add 0 to get to the first one, add 1 to get to the second, etc.)
6:22:19
Zhivago
Now imagine that you're transforming from two dimensional to one dimensional coordinates.
6:41:26
aeth
To translate what I think the article is saying into CL terms, compare the 1-based (let ((end 10)) (loop for i from 1 to end collect i)) to the 0-based (let ((end 10)) (loop for i from 0 below end collect i)) and they seem fairly equivalent, but how do you get an empty one? You set end to 0. Going "from 0 below 0" seems more intuitive than going "from 1 to 0".
6:44:50
aeth
i.e. dealing with the range "start <= i < end" instead of "start <= i <= end" makes more sense when it's empty
6:48:56
stylewarning
beach: The other 1/2 hopefully I'll be granted an additional evening to add to. :)
6:55:11
Zhivago
Just describe the end of the range in terms of the start of the following partition -- e.g., 1~3 contains 1 and 2. Now 1~1 contains nothing.
7:07:44
krwq
trying to define following c function with cffi: int utimens(const char *, const struct timespec tv[2]); - I've tried defining tv[2] as a struct with two fields but defcfun doesn't let me use (:struct mytype) as a type
7:09:12
phoe
krwq: I am not *too* sure but I remember this might be a CFFI limitation that doesn't let you address struct arrays directly but only indirectly via a pointer.
7:10:21
krwq
phoe: do you think splitting args in some way would be equivalent? what i mean that they end up on the stack either way - I'd rather avoid such hacks but on the other hand don't want to write C-wrapper for that
7:11:13
phoe
krwq: I'd avoid hacks completely when interacting with the C layer. But that's just my paranoia.
7:12:48
stylewarning
krwq: fwiw, there's this: https://www.quicklisp.org/beta/UNOFFICIAL/docs/fsbv/doc/index.html
7:13:17
stylewarning
I think it was merged into CFFI. I ran into it when trying to deal with complex numbers.
7:13:35
flip214
fourroot1: Dijkstra's article explains it, http://www.cs.utexas.edu/users/EWD/ewd08xx/EWD831.PDF
7:46:23
krwq
actually seems like c passes foo[2] as a pointer and not as sizeof(foo) * 2 bytes which makes it easier in my case
8:13:55
leedleLoo
Hi, I was wondering how read-line is buffered. When the read-line function is called, is only one line read from the stream, or are potentially multiple lines read and stored (up to 4096 bytes, for example)?
8:19:17
krwq
p_l: i see that now - I previously thought that when you have fixed size arrays they are treated as large struct (n*sizeof(struct)) but seems that's not the case
8:20:30
jackdaniel
leedleLoo: if you are interested in bigger reads, take a look at library alexandria
8:24:00
leedleLoo
jackdaniel: Thanks, that function is actually similar to what I was going to do: use read-sequence and then pass into read-line
8:29:04
leedleLoo
krwq: To define an array of structs, I think you'll have to pass in a pointer and the number of elements in that pointer: int utimens(const char *c, const struct timespec *tv, int n)
8:29:52
krwq
leedleLoo: that's what I did already, I didn't realize that C was passing pointers for fixed-size arrays
8:43:07
jackdaniel
if you hadn't left I'd tell you, that usually you may pass array as a pointer and vice versa, but it is not conforming C code
9:10:53
dim
I think they call it “flexibility”, used to say it's a very good portability feature of the standard, all those non-conforming areas, and now they brag about optimisation opportunities
9:14:49
flip214
dim: only if you use(d) something you can really discuss pro and contra. Else you're just repeating hear-say.
9:20:33
rme
I was making a joke by alluding to an old paper Brian Kernighan wrote, titled "Why Pascal is not my favorite programming language".
9:26:25
dim
and I picked the “not my favorite” phrase because I knew it was charged with some history, only I don't know nearly enough about it
11:03:45
borodust
Xach: sorry for bothering: a couple of libraries are fail to build for a few days straight because the system i mentioned later in a comment is still not added. Are there any problems with this particular system (`cl-muth`)?
11:04:23
borodust
Xach: link to the failing build: http://report.quicklisp.org/2018-02-26/failure-report/cl-flow.html#cl-flow_tests
11:05:01
borodust
Xach: link to the comment https://github.com/quicklisp/quicklisp-projects/issues/1445#issuecomment-367437114
11:16:03
pjb
jackdaniel: read-line doesn't always read a line: when it reaches end-of-file, it may read a partial-line (a line without a newline), or nothing, returning the eof-value.
11:16:56
pjb
Very few CL functions are specified to always return something! (In general, they can make non-local exits, in case of errors or otherwise).
11:17:46
jackdaniel
reads as in "performs read, which may fail or whatever, but it doesn't try to read a character, or to read multiple number of lines". given context I think that above answer was perfectly fine
11:18:22
jackdaniel
without adding, that if you put integer in place of a function it will signal an error. if you put vector in place of a list it will signal an error. etc
11:19:14
pjb
Yes, but I would like programmers to be more unbiased vs. the various possibilities. We have to take into account all the cases.
11:20:30
jackdaniel
pjb: mentioning all the cases (including irrevelant ones) just clouds the message and makes it not understandable, so I strongly disagree
11:21:34
loke
I like checked exceptions, and I feel that cases where they programmer is not in control _should_ be documented. I.e. READ failing is something the developer always have to take into consideration. There is no way you can program in such a way as to not have to deal with it.
11:21:45
jackdaniel
you do not consider the very special case of explaning things: the reason why you do explain
11:36:43
pjb
unix (and then posix) is not civilised. Multics tried to. But unix recognized that there were "The facts of life."
12:34:21
shka
(print (postmodern:sql-compile `(:order-by (:select * :from "pac_paths") epi_id stay_begin_dt)))
12:40:50
dim
what about having .sql files in your repository instead? I find it way easier to manage
12:41:24
dim
you could even go as far as https://github.com/krisajenkins/yesql ; certainly there's something to that effect in CL?
12:41:53
Xach
I find I like to use html templates rather than constructing it from cl-who or similar...
12:45:03
dim
Xach: yes and no, you shouldn't find any loop constructs and such, it should feel like writing a CL function in SQL, not like preparing a textual data
12:47:16
fe[nl]ix
the readme of yesql makes me think the author never had to programmatically build a query from fragments
12:47:30
dim
shka: yeah I'm not offering practical-now advice, just… consider that SQL is code and that long term you might like to have .sql files in your source tree, that make things easier
12:48:07
dim
fe[nl]ix: I'm highly dubious of building a query from fragments being something you need rather than something you've been used to
12:48:55
dim
shka: I think we agree, or should I use other wording than “consider”, ”you might like to”?
12:49:43
fe[nl]ix
dim: I've had to do that quite often, e.g. adding joins and filters based on a user query
12:51:12
dim
when you have say 3 lisp functions that does almost the same thing but not quite and you want to sometimes inject variations/filtering in the inner-loops, would you have a macro that generates the variants at run-time?
12:51:25
shka
dim: besides some people like to write bad code, and should be allowed to do so if it makes them happy ;-)
12:52:31
dim
fe[nl]ix: on more practical grounds, when things don't run like intended in production and you need to fix one of the queries, but not the others, it's a big problem where it should be a simple patch to the .sql file
12:53:09
dim
having been dev & dba a lot in previous jobs, building query from string pieces in the code is something I loathe nowadays, it's only going to cause maintenance problems down the road
12:53:42
fe[nl]ix
the were cases at the Lisp conferences where the presenter spoke highly of being able to turn an HTTP query into a lambda to cl:compile then funcall
12:54:35
fe[nl]ix
dim: and 3 functions is very little, I've had cases where 5 tables would have lead to a total of 31 join combinations
12:56:05
dim
“but it is generic and we allow the user to search for anything anywhere, we can't know what he'll be interested into” --- yeah, you didn't do your job
12:56:42
dim
anyway, it's just my opinions for having had to deal with that as not be allowed to tinker with the code, and then see developers trying to fit my SQL fixes/improvements back into their code
12:57:02
dim
and refactoring huge portions, or refusing to fix production problems because it would be too much of a change, all for just a SQL query
12:57:17
fe[nl]ix
as a user, I'd hate to use an application that is unnecessarily constrained just because the programmers want an easy life
12:57:32
dim
I'm saying any of you guys fall into that misthinking, but SQL is code and needs patching to ensure good production behavior, just as the rest of the code
12:58:44
fe[nl]ix
where I work, once a backend is goes GA, the data model basically never gets changed
13:00:07
dim
I'm failing to find a nice humouristic illustration of the point I was trying to make, blah
13:02:20
jdz
I agree with dim, coming from Rails and Django, where they use fancy SQL-building DSLs, which I've always found lacking. Mostly because of the inability to use nice SQL features.
13:18:09
Xach
Working with Lisp has made me appreciate the "living system" model of SQL servers more.
13:19:03
Xach
Also, I would like a more query-oriented way to get data from the running Lisp system.
13:19:45
Xach
system data, that is, like "show me all functions with both &key and and &optional" or "all packages without a docstring" and things like that.
13:20:08
Xach
I know there are ways to get that info "manually", but it would be interesting to me to have a more uniform query system/syntax.
13:24:27
AeroNotix
Xach: is it possible to wrap the def* type forms with something that creates a database of what you need?
13:28:04
Xach
AeroNotix: most systems already keep that data around anyway. that's how slime gets its arglist info
13:31:16
p_l
Xach: I think it's something that is really missing from *Common* Lisp, all the extra details on introspection or detailed organization of memory that were provided in systems it derived from
13:31:46
Xach
p_l: my general feeling about "missing" features is "well, they had to stop somewhere"
13:32:28
p_l
on one hand, yes, on another there are some cases where IMO they concentrated too much on "we have enough pages as it is"
13:33:41
Shinmera
My thought is I don't really know what you mean by it. Do you mean retrieving the original documentation forms?
13:34:05
Shinmera
Okey. In that case you could just store them however you like in your custom formatter, no?
13:35:34
Shinmera
So far I'm leaning towards not wanting it as it seems like storing the original format isn't needed for a lot of cases, and those where it is letting them handle their own storage seems smarter as they can decide exactly how to do it.
13:36:28
Shinmera
I can see an angle where primitive formatters might want to just store the original expression, but that seems like a small case that possibly just hinders most cases.