freenode/lisp - IRC Chatlog
Search
2:28:45
pfdietz
So, if you always use :, you will know you are only looking at the external interface of the package, not internal symbols that may change out from under you. In general, it's a code smell to use ::.
4:00:31
White_Flame
tinga: packages (namespaces) are a flat, global space. The modern way to avoid collisions is to use long package names and package-local-nicknames to have a scoped, easier name for it
4:00:55
White_Flame
but if you're learning and are mostly using libraries instead of creating a bunch of your own packages, you really don't have to worry about that
4:29:43
aeth
Yes, using :: is a code smell, but sometimes it's not on your end. If someone didn't export something and you actually need it and need to :: to get to it, then it's probably a bug.
4:30:23
aeth
In particular, so many libraries don't export stuff that only exists as a type, e.g. structure classes, standard classes, manual DEFTYPEs, etc... which you might need if you want to use CHECK-TYPE.
4:41:45
beach
Well, if the library creator meant for a class to be subclassed, its name should have been exported.
5:35:56
sveit
slynk/sly has awesome and very usable backreferences for statements evaluated in the REPL, is there something similar to get access to values eval'd from a buffer?
5:37:17
sveit
or compiled? I am a bit surprised if not given how good the support for getting back values is otherwise. relatedly, it doesn't seem there is anything built-in to copy code to the mrepl from a buffer, although it exists for "buttons", is that by design?
6:18:15
splittist
beach: on the other hand, not meaning something to be subclassed is not the same as meaning it not to be subclassed. I'm sure I don't see all the ways my stuff can be extended and enhanced when writing a 'library'.
6:23:55
asarch
I've tried several ways but I can't. How would you store the binary content of a #<FLEXI-STREAMS::VECTOR-INPUT-STREAM {10051D57A3}> into a file?
6:25:38
asarch
Parsing the POST message, I can get the "pointer" of the buffer with: (let ((file-uploaded-buffer (second (car _parsed)))) ...)
6:39:59
Nilby
asarch: You could read it into a buffer and use alexandria:write-byte-vector-into-file, or you could use uiop:copy-stream-to-stream to an open octet file stream.
6:41:07
asarch
What is exactly FLEXI-STREAMS::VECTOR-INPUT-STREAM? The pointer to the buffer, the content itself, or a structure that contains both things
6:45:46
Nilby
There's not really an analogue in C, but you would probably use fwrite of a buffer pointer in a stream struct in C.
6:46:48
asarch
So, from that object I get the vector and from that vector I "put" those bytes in another stream pointing to a file, right?
6:50:09
Nilby
You don't need to get the vector. You can just read the bytes from it, and write them to an open file stream with a compatible element type.
6:56:18
Nilby
But I would use something like uiop:copy-stream-to-stream, which does the whole thing at once.
7:03:13
asarch
(with-open-file (file-output-stream "foo" ...) (uiop:copy-stream-to-stream #<FLEXI-STREAMS::VECTOR-INPUT-STREAM {10051D57A3}> file-output-stream)))
7:04:32
Nilby
let's thank Edi for making such flexible streams, and Faré for putting a wacky library in asdf.
7:07:03
asarch
_parse is where you can get all the data from the POST message which has a form of: (("file" #<FLEXI-STREAMS::VECTOR-INPUT-STREAM {10051D57A3}> "139626492_3531143143657758_2613955532857309082_o.jpg" "image/jpeg"))
7:07:49
asarch
So, for example, to get the name of the uploaded file would be with: (let ((uploaded-file-name (third (car _parsed)))) ...)
7:08:34
asarch
And, to get the "handler" of the buffer: (uploaded-file-buffer (second (car _parse)))
7:12:59
Nilby
Well, you need to open the file stream, so you probably need a with-open-file in there.
7:25:01
asarch
We get this beautiful piece of code to upload files to your PC from your cellphone at home :-)
7:26:28
Nilby
I think if you add an element-type the copy-stream should work: (uiop:copy-stream-to-stream uploaded-file-buffer file-stream :element-type '(unsigned-byte 8)))
8:06:28
ralt
(format t "~a" foo) vs (format t "~A" foo) -- what's the difference? Is it a stylistic one at best?
11:38:54
beach
I don't know any by heart. And there are several. Do you mean the one written by Fare et all when he worked for Google?
11:42:41
beach
It is not a very detailed style guide. It is more about understanding what style is for and why it is important.
11:44:22
beach
Like it says, it is about memory. You want the person reading your code to have to remember as little as possible in order to understand the code. And that goal has several consequences...
11:45:22
beach
You want to get rid of special cases first, so that the reader does not have to remember to look for them over a long chunk. Example: recursion should start with the base case.
11:48:04
beach
The WHEN/IF thing is an example of both. When you use IF, you make the reader remember that there is an `else' part coming up when he or she is reading the `then' part.
11:48:30
beach
So if there is no `else' part, then you have unnecessarily wasted the memory of the reader.
11:49:00
beach
By using WHEN instead, you immediately tell the reader that there is no need to remember to look for any `else'.
11:51:15
flip214
yeah.... but when I switch windows, the first thing I see is the last line written.
11:51:42
beach
Memory is also the reason for the rule about using the most specific construct that will accomplish the task at hand.
11:52:55
beach
when the ... are all lists, then mapcar is more specific, so it should be used in that case.
11:54:36
beach
ldbeth: Also, everything "can be figured out". That's not the point. Again, the point is how long it takes the person reading your code to figure it out.
11:55:45
beach
Yes, but again, this is not about personal preference, unless of course, you keep your code to yourself.
11:57:02
beach
It seems whenever style is discussed here, it always ends with people stating their personal preference, as if that is the important thing here.
12:14:37
Posterdati
please I need to write a small lisp interpreter on a microcontroller, shall I use scheme?
12:20:06
Posterdati
well I need the bnf coded grammar for a small subset of lip, I thought about scheme, from this project instead https://github.com/hmgle/yascm
12:20:46
jackdaniel
Posterdati: I think that this is offtopic on this channel, so prolonging the discussion is not a good idea