freenode/#lisp - IRC Chatlog
Search
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.
14:22:19
pjb
Murii: also, if your language supports unicode, it may not be the best choice to make strings vectors.
14:23:01
jackdaniel
technically string is a set of symbols from a specified alphabet, no vector required
14:23:18
pjb
Since the properties of unicode strings are so strange, vectors of glyfs, vectors of code-points, or vectors of characters are all inconvenient. Some argue that even having characters is inconvenient, when you use unicode.
15:07:19
TMA
hajovonta: if you restrict yourself to English the intuition is fine. but for more complex languages you soon run full speed into a wall with it
15:09:48
Shinmera
Often times a unicode string will be taken as a vector of code points. Unicode allows you to compose characters through multiple individual code points, where the order does not necessarily matter. Thus, as a representation of a "character string" different vectors represent the same thing, but are no longer identical.
15:10:13
TMA
because the properties of sequences no longer hold -- if you concatenate sequences you would probably assume that the resulting length will be the sum of lengths
15:12:01
hajovonta
we have several strange characters in our language (Hungarian) like á, é, í, ú, and ö, ő, ü, ű
15:12:35
hajovonta
but, when I write "árvíz" and concatenate "tükör" then "árvíztükör" is a sequence of 10 characters
15:13:16
Shinmera
Unicode has code points for just the ticks, so you could write a+tick, as two code points, which would be a string of length 2 in most implementations.
15:13:44
TMA
hajovonta: say that you concatenate 'hajov' and 'onta' in a CV sylabic script ... the first has 3 characters (ha-jo-v) the second has 3 (o-n-ta) ; but the concatenation has 5 not 6 (ha-jo-vo-n-ta)
15:15:22
hajovonta
but it doesn't matter how many code points make up a character. We can just count the characters, can't we?
15:17:58
TMA
hajovonta: why yes. sometimes. in other times what constitutes a character is hard to tell. ... IIRC, in Spanish ll is a single character though two codepoints. ch is a single character in Czech
15:19:35
TMA
hajovonta: so when you see the string "chill", you do not know how many characters you have
15:20:35
dlowe
generally, when you want to know the "length" of the string, you want to know a) how many bytes does it take up or b) how many pixels will it take to render this string, both of which have satisfactory answers.
15:21:28
dlowe
A perverse mind might want to know it in order to find the maximum valid index of a character.
15:23:03
hajovonta
15:23:02 - jackdaniel: technically string is a sequence of symbols from a specified alphabet, no vector required
15:24:04
hajovonta
based on jackdaniel's definition, a string is a sequence of symbols from a specified alphabet
15:24:08
jackdaniel
characters are symbols of "text" alphabet, and that's what usually languages implement
15:24:16
pjb
hajovonta: unicode strings are decomposed in glyps, that are defined by a sequence of code-points of variable length.
15:24:29
hajovonta
I agree that the number of characters can be different when using different alphabets
15:24:46
pjb
hajovonta: the notion of string as a sequence of character would imply that a character is an object of variable length.
15:25:26
pjb
hajovonta: no implementation implement characters this way, because it makes for very complex objects, compared to the usual single byte for C char, or 32-bit word for unicode code-point.
15:26:21
jackdaniel
(what I meant, that one glyph is element of the alphabet, not its code-points, so it is irrevelant to the definition)
15:26:29
pjb
There's also the problem of normalization, such as the various unicode representation of á, or the problem of ligatures.
15:26:58
pjb
jackdaniel: ok, you're implementor. I dare you to implement ecl characters as variable-length sequences of code points…
15:29:00
pjb
hajovonta: by the way, even without going full unicode, just with ascii, you have the distinction between characters or ASCII control codes.
15:29:14
jackdaniel
yes, and when you say (nth *string* 18) it won't take 18-th code-point, but 18-th character
15:29:34
pjb
hajovonta: usually implementations make strings vectors of characters, with virtual characters corresponding to ascii control codes, which has no meaning.
15:30:39
jackdaniel
right, the only important thing is that the sequence is finite, alphabet may have infinite number of possible symbols
15:30:43
pjb
hajovonta: so far, even with unicode, it's finite (and way bigger than 2^21), but just let the user combine the code-points without limiting the number of combinaisons, and you get an infinite number of characters!
15:31:28
pjb
hajovonta: in any case, your question is irrelevant: it could indeed (and should IMO) be done that way, but it is not done in practice by implementations!
15:33:20
dlowe
which makes it impossible to both support the notion of a unicode character and the CL spec.
15:36:05
dlowe
pjb: sure, but you'll need some way to access them without decomposing them on the fly.
15:37:25
hajovonta
but a character can be anything, like "djshfkjdhskh". In a hypothetical alphabet, this can be one character.
15:38:11
pjb
basically, IIRC, you can have up to ten combining code-points following a non-combining code-points.
15:39:32
pjb
This would have the advantage, that you could represent most common characters as fixnums.