freenode/#lisp - IRC Chatlog
Search
18:24:12
jcowan
Lisp-flavored C is not uncommon, though it usually doesn't escape particular Lisp implementations.
18:30:09
kristof
(let ((x (the single-float 0.1)) (y (the single-float 0.2))) (the single-float (+ x y))) => 0.3
18:34:35
jcowan
it so happens that when you add the nearest approximation to 1/10 to the nearest approximation to 2/10', you get the nearest approximation to 3/10.
18:34:50
jcowan
(this is in double-floats, I don't have single-float support handy with a printer I trust)
18:38:09
kristof
D also does this. I presume it has something to do with the way floating points are printed from their binary representation and I know there's some tradeoffs to be made there
18:38:13
aeth
SBCL does something special with floats. Even double-floats. I wrote something that ran in SBCL, CCL, ECL, and CLISP... and for one of the five values, the error was really huge in all of them except for SBCL.
18:38:46
kristof
I wonder if this is the first time someone came in to this channel to complain of correctness and utility
18:41:13
aeth
Well, (defun foo () (let ((x (the single-float 0.1)) (y (the single-float 0.2))) (the single-float (+ x y)))) is compiled to constantly return 0.3 so I'd test with (defun foo (x y) (declare (single-float x y)) (+ x y)) (foo 0.1 0.2)
18:48:51
jcowan
aeth: 0.30000000000000004 and 0.3 are two tokens for the same double-float, but the former is in some sense the canonical one.
18:55:57
kristof
anamorphic: (loop for (sym val . rest) on '(a 1 b 2 c 3 d 4) by #'cddr do (print sym))
18:56:12
jcowan
Scheme requires it, and AFAIK the last holdout against doing so has now given in. There is no C requirement to do so, but at least glibc always prints the shortest correct representation. CL doesn't have a requirement either, but I'd be surprised if any CL implementation does otherwise.
18:56:22
kristof
however that will give you the final nil so you should throw a when clause in there
19:02:06
kristof
I was confusing the return value of the loop function for the print action. The first thing I wrote works just fine.
19:04:10
kristof
does slime support a way to do newlines at the prompt? Sometimes I don't want to load forms from a scratch buffer, I just want to write in the single buffer.
19:15:51
phoe
it does support them as long as you do not have a complete form; for example, "(+ 2 2)" and RET triggers evaluation but "(+ 2 2" and RET creates a newline.
19:16:19
phoe
I frequently delete the last closing parenthesis after typing the opening one creates a pair, if I expect to be writing a multiline form.
19:17:03
kristof
SBCL's repl does but slime does not... on Atom, at least. Does it have that before on emacs?
19:32:36
LdBeth
For slime the editor processes the form rather than the Lisp itself, it doesn’t know very well on when to send it, sometimes it even applies to GNU/Emacs
20:14:05
aeth
In SBCL, SLIME's #'sin is (FUNCTION (T) (VALUES NUMBER &OPTIONAL)) and (introspect-environment:function-type 'sin) is (FUNCTION (NUMBER) (VALUES (OR (SINGLE-FLOAT -1.0 1.0) (DOUBLE-FLOAT -1.0d0 1.0d0) (COMPLEX SINGLE-FLOAT) (COMPLEX DOUBLE-FLOAT)) &OPTIONAL))
20:14:56
aeth
(And it's not for portability, I don't think either even has function types in the other implementations)
20:18:27
Bike
"slime's" is the derived type, whereas the one you attributed to introspect environment is the declared type
20:22:51
aeth
In SBCL (and I think just in SBCL) it has the line TYPE: (FUNCTION (T) (VALUES NUMBER &OPTIONAL))
20:23:38
aeth
But personally if I was for some reason debugging something involving #<FUNCTION SIN> (obviously this is just an example) then I'd find the declared type to be more useful.
20:24:14
aeth
Well, I (setf *print-case* :downcase) most of the time, but I keep having to restart SLIME to switch implementations/etc.
20:24:36
Bike
as you can see from looking at the source, slime-inspect on sbcl for functions uses the simple-fun-type that's actually in the function object, rather than the declared type
20:26:56
aeth
Well, this is weird. (sb-disassem:disassemble-code-component #'sin) shows the very small entry point of a T input value. I declare stuff all the time and there's usually a check in the part that's in sb-disassem:disassemble-code-component but not in cl:disassemble
20:35:49
aeth
Actually, what I think is going on is that SBCL's declaim ftype and SBCL's type declarations are separate things, but when you declaim ftype for something you write you also type declare or something. (declaim (ftype (function (number) number) bar)) (defun bar (number) (sin number)) will produce a #'bar as if I did a (declare (number number)) even though I didn't.
22:00:46
skidd0
or, how can i directly manipulate the lack.response reesponse structure before sending?
22:15:28
jcowan
Well then, why bother to have external symbols at all and require a (slightly) more verbose syntax to access them from other packages? (This is not a rhetorical question.)
22:34:02
skidd0
to get access to the lack.response, would I want to do something :around the CALL method?
22:56:39
Bike
skidd0: it doesn't replace, but if your :around method doesn't call-next-method the original method will not be called
23:56:10
skidd0
I'm getting an error where hunchentoot doesn't know how to handle options http requests
1:28:34
kooga
(setf (lack.response:response-headers *response*) '(:access-control-allow-origin "*"))
1:29:52
skidd0
also, i figured out that I needed to add a options verb to the routing library i'm using (snooze)
4:00:27
beach
In a first-class global environments, I have a table called slot-readers and a table called slot-writers. These tables are indexed by symbol names.
4:00:29
Bike
in ecl and clasp direct instances of standard object use a hash table from slot names to locations.
4:01:19
beach
... then those tables work like the function entries in the first-class global environment.
4:02:22
beach
slot-value with a constant slot name gets rewritten to (funcall (car (load-time-value (find-reader-cell <name>))))
4:03:19
beach
I think SBCL must do the same, modulo the first-class global environment, and the function cell.
4:08:29
Bike
also wait, what happens if you have like (defclass foo () ((x :reader foo-x))) (defclass bar () ((x :reader bar-x))) (slot-value some-object 'x)
4:11:46
beach
In my scenario, (slot-value some-object 'x) would be translated to something like (funcall (car (load-time-value (find-reader-cell 'x))) some-object) and the cell would contain a generic function that dispatches on the class of some-object.
4:11:55
Bike
if the effective method just calls the accessor method, the discriminating function just reads from or writes to the slot directly
4:15:22
Bike
also the fast path i mentioned only happens if it's an object standard enough to not have custom slot-value-using-class methods possible. forgot that caveat
4:15:35
beach
Also, until a few years ago, I used slot-value for "internal" access, and slot accessors only for the public interface.
4:16:29
Bike
i'm not sure what the main reader method can do besides calling slot-value-using-class, i guess
4:18:17
beach
He had classes where slots were implemented as special variables so as to make it thread safe.
4:18:55
aeth
What I tend to do for internal setting is :accessor %foo :reader foo because that way I can use with-accessors on %foo without surprising behavior (i.e. only being able to set)
4:20:59
beach
So, in that case, SLOT-VALUE can not be optimized to do a direct slot access, of course, since there is no slot-location.
4:21:36
Bike
i have been thinking on and off about adding more interdependencies between methods in fastgf. for example, within a method body replace accessors with direct slot reads when possible, and then recompile the method if there's a change so it works transparently
4:21:50
Bike
i bet it would make it faster, but it would be pretty involved to maintain everything correctly
4:26:01
beach
So, I think I'll have to add SLOT-READERS and SLOT-WRITERS to the SICL first-class global environments.
4:31:02
beach
This stuff is frequently done "manually": (defgeneric foop (x) (:method (x) nil) (:method ((x foo)) t))
4:33:03
beach
Bike: Let me take a break and think about that idea. I think better when I am not at my computer.