freenode/lisp - IRC Chatlog
Search
21:02:25
Xach
aeth: that's one option. (load "asdf.lisp") is another. you could mix a compile-file into there too.
21:05:02
aeth
This seems to keep the version the same even though it loads (if you turn silent off): (list (asdf:asdf-version) (progn (ql:quickload :asdf :silent t) (asdf:asdf-version)))
21:06:31
Xach
ralt: I am not interested in pushing an implementation's version past where the implementation maintainers have chosen.
21:07:39
aeth
There are a bunch of fixes from 2020 for package-local-nicknames in newer ASDF versions than most (any?) implementations seem to provide. e.g. https://github.com/fare/asdf/search?q=nickname&type=commits
21:13:12
Xach
You can quickload asdf if you download asdf sources and put it someplace asdf can find it.
21:14:42
aeth
So I guess if you use something fixed in 2020, you have to get everyone to upgrade ASDF, and you have to have your CI check out the ASDF repo into local-projects
22:28:06
phantomics
a question: why does entering numbers in scientific notation always yield a float? Like 10e10 returns a float when the number can be expressed as an integer. Is there a way to enter numbers in e-notation yielding ints when possible?
22:29:55
aeth
You can do (round 10d10) but you'd need enough precision in the original, e.g. 10e10 (equivalent to 10f10 by default) won't give you the exact answer
22:40:27
_death
phantomics: when writing numbers in scientific notation, you deal with real values.. that some of them can also be represented as integers is incidental.. if these translate to a different type, it would be inconvenient because usually a programmer's choice of whether to use floats or integers is explicit
23:01:47
aeth
_death: well, I mean... 9.8e10 is an integer and 9.8e0 isn't, but it's not like you couldn't have scientific notation that results in a rational (bignum/bignum, rather than an integer) or error if it's not an integer, or have some rounding rule, or...
23:04:11
tinga
I'm trying to run an existing project and it complains that ASDF package doesnt exist, so I added (load "/usr/lib/sbcl/contrib/asdf.fasl") to the init file, now it complains that package QL doesnt exist. I suspect it might be quicklisp but while (load "/usr/share/common-lisp/source/quicklisp/quicklisp.lisp") pointed me to run (quicklisp-quickstart:install), which I did, it now still complains about QL not existing.
23:06:29
_death
aeth: 9.8e10 is not an integer in Lisp.. it is an integer in math, but some languages choose to support multiple representations for a single mathematical value..
23:08:01
aeth
_death: I mean a mathematical integer. The fact that some words are overloaded with math words with separate meanings can be confusing at times. In Scheme land, they don't do that (except with vector), but then you get the confusion of 9.8 being an integer? so when you're a programmer you really want an exact-integer? instead when you want an integer... and so on.
23:09:53
aeth
Anything that can be a float can also become a rational, as long as it's either an exact operation (like 9.8 * 10^10 is) or has a specified rounding precision.
23:10:38
aeth
CL has both RATIONAL and RATIONALIZE to do this, with the latter generally producing more intuitive results when working on base-2 (rather than base-10) floats.
23:11:21
_death
all I'm saying is that it would be inconvenient if 9.8e10 is an integer while 9.81e10 is not
23:12:43
aeth
_death: You said earlier that scientific notation deals with reals, which isn't true in programming.
23:13:18
scymtym
while phoe is joking, SBCL actually has http://www.sbcl.org/manual/index.html#Decimal-Syntax-for-Rationals
23:13:22
aeth
The only reason why stuff like the scientific notation literals, SQRT, etc., don't produce rationals is that you'd need some global or extra parameter for precision. Floats have fixed precision.
23:15:54
aeth
_death: mathematical real numbers (not the type CL:REAL) are infinite, whereas floating point are fixed-length. They are not reals. You can't even get all reals on a magic computer with infinite precision and infinite RAM: you can only get computable numbers.
23:16:47
aeth
The main difference between a RATIONAL and a FLOAT is the way the printer treats them: 258/25 vs 10.32
23:17:53
aeth
It works. Mostly. It still prints rationals as rationals, instead of as the default floating point type.
23:19:26
aeth
_death: Actually, exactly the opposite. Every other field has infinite pedantry. Mathematics is precise. The only confusing thing when applying mathematics in a computer science concept is that a lot of the terms have two meanings (like math's real numbers vs. CL:REAL)
23:20:21
phantomics
In that cast, if I want to read e-numbers as either float or decimal, depending on whether the output is a whole number, I can just check if the output from nEn has a fractional part that's bigger than the float epsilon, and if it isn't I evaluate the same number as nRn
23:20:28
aeth
_death: And in this case, it actually has an application. The application is that CL:RATIONALs can be used as "exact" floating points with just a little bit of work.
23:21:51
aeth
Someone probably has already written a SQRT* that will call SQRT if a float, but keep rationals as rationals to the desired level of precision. (Note: This isn't ISQRT, which rounds down)
23:49:53
Xach
kpoeck: thanks. how can i find that out for myself? i looked for things named asdf and none of them seemed to be asdf. (maybe i looked wrong)
23:53:06
kpoeck
In our build script it refers to the asdf version: https://github.com/clasp-developers/clasp/blob/master/wscript#L320
23:57:07
Xach
kpoeck: thanks, i thought there might be an asdf.lisp or similar. thank you for the link to the script.
0:04:55
Bike
yeah it does the source concatenation dealie so asdf.lisp isn't actually in the distribution
0:05:58
kpoeck
yes this is done by ${MAKE-make} --quiet in https://github.com/clasp-developers/clasp/blob/master/wscript#L324
0:09:14
kpoeck
so basically we pull the asdf sources from https://gitlab.common-lisp.net/asdf/asdf.git and build asdf.lisp with ./waf update_dependencies in the clasp build process
1:30:44
tinga
Or how do packages allocate namespaces at run time, is it a hard coded mapping or configured somehow?
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?