freenode/#lisp - IRC Chatlog
Search
4:15:28
didi
Has anyone played with the idea of a function returning a variable number of values? For example, a matching function might return (values x) if I ask for a single match and (values x y z) if I ask for three matches.
4:22:27
White_Flame
when receiving the values, you probably want to multiple-value-bind with &optional or &rest
4:23:03
White_Flame
other than that, I don't think there's anything abnormal about it. It's supported by the language
4:23:48
White_Flame
SBCL might whine about optimization issues with the number of values not being fixed, depending on your speed setting, but it'll deal with it
4:33:27
White_Flame
yep, but if you set speed 3, it whines about every place it can't fully optimize
4:35:26
White_Flame
wrote it a long time ago, not sure how accurate it is for current versions: https://pastebin.com/Rmyazt4z
5:19:40
pjb
didi: (ql:quickload :cl-ppcre) (cl-ppcre:scan "(a)" "hello a world") #| --> 6 ; 7 ; #(6) ; #(7) |# (cl-ppcre:scan "(a).*(b)" "hello a world before") #| --> 6 ; 15 ; #(6 14) ; #(7 15) |#
5:20:44
pjb
didi: there's no difficulty in writing such a function. But if the number of values is not known at compilation-time, then you will have to use multiple-value-list and cons a list!
5:21:42
pjb
(loop repeat 3 collect (multiple-value-list (values-list (make-list (random 10))))) #| --> ((nil nil) (nil nil nil nil nil nil nil) (nil nil nil)) |#
5:21:47
White_Flame
multiple-value-bind and &rest, if used immediately and not passed around, has the possibility of not consing
5:27:28
slyrus__
I'm looking for a lispy approach to "time travel" through a modestly-sized (read: small) data set, where I want to be able to see the "state of the (again, relatively small) world" at a particular point in time. Anyone have any suggestions?
5:28:13
slyrus__
beach has a library called Clobber that might be a good place to start, but I figured I'd see if others have dealt with this or similar problems before.
5:28:53
White_Flame
either that, or keep a changelist of undo/redo function objects that you can use to traverse time
5:32:51
didi
SBCL seems to not care about not receiving some values. (multiple-value-bind (x y) (values) x y) => NIL
5:33:27
White_Flame
" If there are more vars than values returned, extra values of nil are given to the remaining vars. " - clhs
5:34:37
slyrus__
thanks White_Flame. I also came across this: https://github.com/smithzvk/Versioned-Objects which sounded like it might be what I'm after.
5:58:40
White_Flame
when performance is critical in inner loops, and you're guaranteed to not to be dealing with numbers or characters
5:59:17
White_Flame
(unless the numbers are guaranteed to be fixnums, but even then I think ABCL doesn't guarantee that fixnums are EQ)
6:08:11
pjb
verisimilitude: EQ is an operator that serves only to detect whether an implementation copies integers and characters or not.
6:08:58
verisimilitude
If you wanted to be mean, didi, you could write Common Lisp that behaves subtly differently between implementations based on whether objects that happen to be numbers or characters are ever EQ.
6:11:41
verisimilitude
EQL is more complex, purely because it can't simply compare a combined tag and pointer value to arrive at its answer.
6:14:57
pjb
verisimilitude: but forgetting about EQ frees some neurons for better things, and you don't have to think whether you can use it or not when you write code, and you don't have to ponder whether something special occurs with numbers and characters when you read it.
6:15:09
verisimilitude
You'll mostly be using EQL, though, didi. When in doubt between EQUAL and EQUALP, just use EQUALP if you're too lazy to look at the documentation.
6:15:41
verisimilitude
Sure, but why are you using Common Lisp instead of something else, at that point, pjb?
8:08:36
White_Flame
let-me-google^Wcliki-search-that-for-you.com: https://cliki.net/site/search?query=csv
8:09:16
White_Flame
including the recommended pages, pointing to cl-csv: https://cliki.net/Current%20recommended%20libraries
8:09:31
shka__
White_Flame: do you understand question "what is the fastest correct CSV parser for CL?"
8:10:11
shka__
i know that clicki exists, i know that parser exists, i just want to know if there is something faster cl-csv
8:10:11
jackdaniel
as you have noted, "correct" doesn't have much sense, "practical" is better; and I daresay all published libraries are practical to some degree
8:10:36
jackdaniel
as of "spped" you should benchmark it instead of asking. someone may tell you "this is the fastest" - how do you know it really is? maybe he didn't mbenchmark?
8:12:31
splittist
presumably a csv library has to deal with arbitrary csv, but your problem domain is narrower, so you could tune your own for higher performance (whatever that might mean)
8:13:38
shka__
splittist: i actually need something general, but maybe i can investigate cl-csv performance
8:14:10
White_Flame
I guess if you read-line, then have each field be a displaced-array into that line, that could work
8:14:37
White_Flame
however, if you have quoted fields with embedded quotes, eg "foo \"bar\" baz", you'd still need to re-render that string
8:15:05
White_Flame
presumably copying out those fields is slow, but read-line might also be a performance pig. You'll have to profile
8:15:51
White_Flame
also if you have quoted fields with embedded newlines, that mucks with using read-line cleanly
8:16:21
jdz
Also the strings that are enclosed in double double quotes so that the double quotes inside don't have to be escaped?
8:16:57
shka__
furthermore, even if i read the whole file into string and build stream on top of that, it does not improve performance dramaticly
8:17:25
jackdaniel
shka__: you claim that it is not I/O bound, so what is the bottleneck? I don't see cl-csv::check-and-dispatch symbol in said package
8:18:40
shka__
jackdaniel: https://github.com/AccelerationNet/cl-csv/blob/3eba29c8364b033fbe0d189c2500559278b6a362/parser.lisp#L359
8:19:05
Jachy
shka__: You could try fare-csv and compare? I'm curious how slow cl-csv is compared to, say, Python's csv module.
8:19:12
White_Flame
jdz: in some data, we ended up using ASCII field separators from the 0-31 control group
8:19:50
White_Flame
Jachy: when doing some comparisons like that, you never know if the python module is implemented in native code, too
8:20:50
jdz
Oh, maybe what I remember is a field that starts with a double quote, which basically translates to it starting with three double quotes.
8:22:23
shka__
anyway, there is stuff like this https://github.com/AccelerationNet/cl-csv/blob/3eba29c8364b033fbe0d189c2500559278b6a362/parser.lisp#L69 that makes me think that there is some potential for performance improvements
8:23:23
White_Flame
I don't think too many people have had need for high-performance csv reading; sounds like you've got a niche to fill
8:26:12
White_Flame
of course, some of the other libs on cliki might be faster for lack of abstracted features
8:31:06
White_Flame
given that the regex should be able to give you the index of the last character of the match, from which you can parse the next field
8:33:23
White_Flame
of course, if the field starts with a doublequote you'd probably still have to search for embedded quotes and perform a transform
8:33:47
shka__
i will try to tune cl-csv first though, writing my own csv parser is considerable undertaking
9:32:27
scymtym
is there an easy way to use gitlab.common-lisp.net's mandatory two-factor authentication without a phone or additional hardware?
12:53:09
Xach
Hmm, is this ok? (defun starts-with (subseq seq test) (and (<= (length subseq) (length seq)) (every test subseq seq))?
12:53:41
Xach
I've done endless variations of a starts-with thing and I don't remember using this. (e.g. mismatch, :start and :end with string= and stuff, etc)
13:56:57
moldybits
sbcl gives me a style warning for (error "invalid thing: " thing) ... oh, nevermind. :)