freenode/#lisp - IRC Chatlog
Search
1:18:44
jmercouris
I always envisioned defun as a special form for declaring a function, but now I see that it is for associating a lambda with a name
1:19:44
aeth
It's more obvious in Scheme, where (define (foo x) x) is just syntactic sugar over (define foo (lambda (x) x))
1:30:34
Bike
and while lambda isn't a special operator, the symbol LAMBDA has a special meaning to the FUNCTION special operator in a way that can be conceptualized as a kind of special operator.
1:31:41
dmiles
backquote would not have entered my mind had quote not been an been a special operator
1:42:13
jasom
man read-byte is poorly optimized on sbcl; slurping a stream with read-byte is slower than slurping a utf-8 stream with read-char...
1:46:10
earl-ducaine
It's been up for a while. (last April) But in case you haven't seen it, the old GigaMos k-machine emulator along with all the associated LMI branch Lisp Machine code has been posted on bitsavers
1:47:32
jasom
If anybody hasn't been able to figure out how to do X with clack, PRs and Feature requests for my tutorial are accepted here: https://github.com/jasom/clack-tutorial/blob/src/pages/getting-started-with-clack.org
1:47:53
jasom
(pretty version here: https://jasom.github.io/clack-tutorial/pages/getting-started-with-clack/)
1:50:51
jasom
There is zero good reason that I can think of for it to be a class, since there is an infinite variation in which keys might be present in it...
1:54:01
jasom
but yes a list of values with no structure is stupid, particularly since defstruct lets you define a tagged list of values...
1:57:41
jasom
where there is one value that you will almost always want, but a second value that you only sometimes want. Plus it avoids consing on most implementations
1:58:11
aeth
values is a nice way to write pure functions where you would otherwise use a very short list or vector that conses to do the same thing, evne if you need the 2nd, 3rd, etc., values.
1:58:55
aeth
Using it a lot will probably add an overhead of maybe one instruction, but it gives you pure functions for "free"
1:59:35
jasom
did they ever figure out a way to implement it efficiently in wasm? There was a tempest in a teapot about that a few years back...
1:59:49
aeth
(It's not really free, but afaik you pay the cost for efficient multiple return values whether you use them or not. But you do need to implement support for them at the compiler level.)
2:00:32
aeth
There are lots of cool things you can do in languages that C++ can't do... good luck getting those efficiently implemented in wasm.
2:03:20
mfiano
Can anyone tell me why uiop:safe-read-file-form coerces floats to doubles (d0 suffix), as compared to uiop:read-file-form which does not?
2:06:55
mfiano
Looks like it's binding *read-default-float-format* 'double-float, but why is it 'unsafe' not to?
2:11:56
mfiano
I just tracked down a bug that stems from this function coercing all my floats to doubles. Looks like I'll have to just safely read on my own. I just don't understand how not coercing is unsafe
2:13:37
aeth
if *read-default-float-format* is 'double-float, you can still get single-float from 1.0f0, 2.0f0, etc.
2:14:30
aeth
I never assume *read-default-float-format* because that has bitten me before, in source code!
2:14:44
Bike
there is no "verbatim". 1.0 can mean any one depending on how it's read. single-float is just the default binding.
2:15:01
Bike
perhaps you could petition fare or whoever mantains uiop to let you provide the float format yourself, though.
2:16:01
aeth
It's always single-float initially. http://www.lispworks.com/documentation/HyperSpec/Body/v_rd_def.htm
2:18:18
mfiano
Thanks. I guess it makes sense to change my machine-generated dsl data format over using my own reader function.
2:19:42
aeth
If I had to read numbers as single-float without the "f0" suffix, I'd probably do what they do in the example to make sure it's single-float and then read it, i.e. (let ((*read-default-float-format* 'single-float)) ...)
2:21:03
mfiano
It makes total sense to change the file data instead, since these files may be used by other developers too.
2:21:14
aeth
e.g. I turn off *read-eval* but I make it configurable just in case someone is using that feature for some reason.
2:21:54
mfiano
ie; unless i write a user api for parsing these files, rather than just provide them for users to do whatever, i should encode the data in an unambiguous method
2:26:31
Fare
Bike, discussed changing the *read-default-float-format* in 2014 or so, and the overwhelming reaction was that ASDF should stick to the standard.
2:27:29
mfiano
The question is, what would be the best way to write out 1.0f0 to a file, such that it is not read and then written as 1.0 ?
2:27:46
Fare
rpg, after it gets merged (or rejected), the document should be updated to reflect the current situation and current plans.
2:28:21
Fare
mfiano, bind *read-default-float-format* yourself inside a with-{safe,standard}-io-syntax
2:32:47
aeth
I tend to just write my own custom writer, though. It's hard to get the output just the way I want it.
2:33:37
aeth
Fare: If short-float is single-float, then it'll write as 1.0, not 1.0f0. It's probably safe to assume a separate single-float and double-float. Conforming implementations that don't do this will probably be broken by some dependency before they get to the unique code.
2:34:20
aeth
It's very easy for some niche Lisp to be broken by a dependency or a dependency's dependency.
2:36:15
aeth
As far as read and write not being portable... ime read tends to work more or less as I want it, but write is trickier because of where it decides to newline long s-expressions.
2:40:44
aeth
Often when I write a custom reader, I'll try to rely on the built-in read where I can get away with using it.
3:19:42
aeth
Fair point. I've mostly used read for things like configuration files and programming languages, where the user is essentially trusted.
3:27:51
jasom
aeth: almost all architectures introduced after 1990 support at least 3 return values with zero overhead (and 8 is not unusual) in hardware; there is no cost to the caller if it doesn't use them, and the cost to the callee is only an extra register store (to marke the RV count)
3:29:23
jasom
aeth: well Power, ARM and MIPS can each do at least 8 (though the common ABIs often don't define that many, it is 100% compatible to use all caller-save registers)
3:32:32
jasom
x86-64 ABI specifies 7 volatile registers, so 6 return values could be done cheaply; I'm not sure if sbcl does this though...
3:34:24
jasom
looks like SBCL on'y uses 4 of them for return values, and one is a count, so 4 will require stack access
3:59:15
cryptomarauder
mfiano: I am a string whore myself which may not work on some systems applications but for keeping the format good on something like 1.0f0 unaltered I throw it in a string like a do tortillas. Otherwise if it's not dealing with standardized definitions which would endure the data integrity in your output you just can't be sure in a portable way.
4:02:42
lildragon
Is there a good book/guide to learn (Common ?) Lisp that is straight to the point?
4:03:12
minion
lildragon: look at PCL: pcl-book: "Practical Common Lisp", an introduction to Common Lisp by Peter Seibel, available at http://www.gigamonkeys.com/book/ and in dead-tree form from Apress (as of 11 April 2005).
4:03:22
lildragon
And Practical Common Lisp is too verbose. I don't care about your dad, I don't need you to repeat the same idea five times for me to learn how a list works.
4:03:32
parjanya
what’s the smart way of getting just some values that get-decoded-time outputs? if I use multiple-value-bind it gives me a warning if I don’t use all the variables... I thought of using multiple-value-list and then selecting just the parts I want, but isn’t there a better way? something like (grab (0 2 4) (get-decoded-time)) to output only the first, the third and the fifth values
4:03:48
lildragon
mfiano: Thanks, see my problem with the book, two chapters in and I am already bored. :P
4:04:21
mfiano
lildragon: That's ok, because the book is very short, and you won't find another like it.
4:05:22
lildragon
"A single record, however, does not a database make. You need some larger construct to hold the records. Again, for simplicity's sake, a list seems like a good choice."
4:05:27
mfiano
You could start with Common Lisp Recipes, which is a bunch of concise "recipes", but it is designed to be a companion to PCL.
4:12:52
parjanya
beach: thanks! is this decent, (list (nth-value 5 (get-decoded-time)) (nth-value 4 (get-decoded-time)) (nth-value 3 (get-decoded-time))), or would be better to collect the values in a list and then extracting what I want from it?
4:14:22
aeth
And for the things you don't use, just do this so the compiler doesn't warn you: (declare (ignore foo bar baz))
4:18:33
pfdietz
Might use it for variables that will just be used in, say, debugging or logging statements that may or not actually be compiled (due to #-/#+ or macros).
4:43:29
lildragon
beach: It looks really good in terms of the content, the user interface is monstrosity though.
4:45:18
lildragon
beach: Couple of hours into finally committing to learn Lisp I see a common pattern across everything lisp related, there is a strong commitment in the early ages of computer human interaction (I avoid the term UX because that is too modern). :P
5:25:03
lildragon
beach: I think it is not that bad after all, thanks for reminding me that it is not that long.
7:16:38
cryptomarauder
Nice chat. You guys never quit being eager to help. I am such a lurker but I get so much with virtually no snark. Golden lol
9:59:24
phoe
On SBCL: (trace (setf config)) ;;=> WARNING: (SETF CONFIG) is not a valid function name, not tracing.
10:06:18
Shinmera
It's been a while since I implemented it, but I remember discussing the available options at the time and coming to the begrudging conclusion that a SETF "pre-processor" is the best way to go
10:06:55
Shinmera
It was something about the SETF facility not giving you access to a variable amount of multiple values, which I needed.
10:07:06
phoe
AFAIK needs to be a custom one because of how Qtools hacks around the reader - only the symbols requested by the client code are generated, et cetera.
10:09:33
Shinmera
Essentially (setf (q+:size foo) (values 400 500)) is read as (setf (q+ set-size foo) (values 400 500)), so in that case it needs two values, but let's say (setf (q+:rect foo) (values a b c d)) needs four and so forth.
10:10:35
Shinmera
Anyhoot, the SETF wrapper turns that into (q+ set-size foo 400 500) or whatever else depending on the VALUES form.
10:11:34
Shinmera
You might think I could just specify like a hundred values or something expecting that no function call will ever need that many, but then you also never get any information from SETF about which values were actually passed and which weren't, so you can't compose the proper call.
11:01:09
makomo
jasom: regarding that cl-json hash table thing from yesterday, are you sure that works?
11:01:35
makomo
because i keep getting an error from the internals of cl-json when the body of my *beginning-of-object-handler* is run
11:13:01
beach
I just hate that kind of error message. It contains absolutely no information that is of value to even the most novice Common Lisp programmer.
11:13:29
phoe
Haha, I just got hit by a similar message an hour ago and spent thirty minutes debugging it.
11:14:23
Shinmera
Rust's compiler is pretty nice about error messages, but I don't know if you could replicate that kind of experience for run-time errors.
11:14:32
makomo
jasom: yup, my bad. i delayed the writing of your "to-keyword" and in *object-key-handler* just forwarded the call to the original handler, but that makes no sense because that handler expects all sorts of internal state to be already built (set up by *beginning-of-object-handler*, etc.)