freenode/#lisp - IRC Chatlog
Search
19:56:10
makomo
phoe: to conclude the whole discussion from today, the "error" with http://rextester.com/CQFO22548 was to assume that *builder* will refer to a compiled-function, right?
19:57:02
makomo
adding a (compile nil (lambda ...)) does fix the "issue", i.e. the difference in results when the file is loaded vs. when it's compiled and then loaded (using clisp of course, sbcl gives the same results in both cases)
20:09:49
Bike
by other stuff i meant like, keeping an inline definition around, informing the compiler to avoid warnings, blabla
20:10:17
cgay
I'm finding that slime-edit-definition doesn't always work when I already have the target file open in my buffer. i.e., it works the first time, when it has to open the file, but then later if I M-. the same symbol it jumps to the wrong place in the buffer.
20:16:50
knobo
cgay: I think you have to recompile the whole file if you edit parts of it (adding or removing lines).
20:20:14
makomo
phoe: i still don't understand why the value returned by *lambda1* is changed after defvar-ing x though
20:21:00
makomo
phoe: it makes sense that, since *builder* is an interpreted function, it might inspect x every time to check whether it's special or not and either return a closure or a function
20:21:31
Bike
oh, well, yes. the interpreter presumably looks up whether the symbol is special at runtime.
20:21:58
makomo
Bike: this is the original example, not the one i linked to you (when i forgot to recompile the file)
20:22:43
makomo
it makes sense that the result of *builder* might be different depending on the specialness of x
20:23:33
makomo
dlowe: when learning something, one of the worst things you can do is say "meh whatever" and drop it, imo
20:24:02
dlowe
makomo: sometimes the experts will say "you're wasting your time on this trivial detail," and sometimes they're right.
20:24:29
dlowe
makomo: the code is open source and no one here knows the answers to the exacting detail you require
20:25:00
dlowe
so I think your best bet (without any irony) is to actually dive into the compiler code for each to see why there's a difference
20:25:51
Bike
evaluating a (lambda ...) might literally consist of just copying the body into an interpreted function object, and not examining it in any way.
20:25:58
makomo
i guess it makes sense, but i thought that since in the first case a closure is returned, that it would just be "hardcoded" within the function
20:26:11
makomo
but i guess a better model would be that it would evaluate X in its captured lexical environment
20:27:55
Bike
it is sort of an ambiguous case though. i can imagine interpreters that would treat it like a lexical binding.
20:28:46
makomo
mhm. so in the end it's implementation defined? and with compiled functions it is guaranteed that X will be considered either a lexical or a dynamic binding, depending on the specialness of the symbol X, as per the clause you linked, right?
20:31:21
White_Flame
SBCL does at least give warnings when you redefine some assumption that it baked in previously
20:36:21
White_Flame
the compiler does not appear to be mandated to bake in compile-time knowledge of specialness
20:37:48
White_Flame
ah, but in 3.2.2.3: "Special proclamations for dynamic variables must be made in the compilation environment. Any binding for which there is no special declaration or proclamation in the compilation environment is treated by the compiler as a lexical binding."
20:44:19
makomo
does (compile nil (lambda (x) (lambda () x))) ensure that the functions returned by the inner lambda will be compiled too?
20:49:23
makomo
"The consequences are undefined if the lexical environment surrounding the function to be compiled contains any bindings other than those for macros, symbol macros, or declarations."
21:52:11
knobo
Would a function created by def be garbage collected (defmacro def () (let ((n (gensym))) `(defun ,n () (format nil "t"))))
21:53:55
phoe
so it will stay around, even if you have no real means of accessing that function after it's defined.
21:58:16
phoe
Like, if a symbol is no longer accessible, then all functions and variables named after that symbol may be collected.
21:58:47
phoe
But I have no idea if such a thing happens. You could try checking it out yourself by defining a finalizer on the created function object and see if it ever gets triggered.
0:34:41
Bike
the reason it happens is that docstrings are associated with underlying functions rather than closures, of course.
0:41:16
pillton
I am not sure I understand the difference between your example and https://plaster.tymoon.eu/view/824#824.
0:43:49
Bike
In my example the two functions almost certainly have the same underlying, eh, code object.
0:49:22
ealfonso
perhaps not a good idea, but in defstruct is it possible to spcify a default init form that uses a previously defined slot? is there a way to access "this"?
0:50:00
Bike
there isn't, but you could define a constructor that uses another parameter as a default
0:50:20
aeth
Whenever I do anything fancy with struct initialization, I tell it to make the constructor a %make-foo and I write my own make-foo constructor using %make-foo
0:51:34
devon
(format nil "~,6F" 3738064606071093/1000000) => "3738064600.000000" ; I'd prefer "3738064606.071093"
0:54:27
aeth
#'float is a bit awkward. It defaults to your default float format (in your case, and in most cases, that's single-float), but if you want to use another float format you have to provide some number of that format, in this case 1d0 (the "d0" instead of "e0" forces it to be a double)
0:57:09
aeth
Actually, apparently the default is always single-float. The difference between #'float and #'coerce is that #'float won't coerce something that is already a float.
0:59:39
Bike
you might want to consider laying out the decimal yourself. it's kind of a pain, but it beats weird rounding unintuitiveness.
1:00:34
Bike
like (multiple-value-call #'format nil "~d.~d" (floor 3738064606071093 1000000)) i mean.
1:02:59
aeth
If you do something like this you should probably write a unit test that compares it to the float version. They could differ, but if the decimal part differs by an order of magnitude or more, that's probably the leading 0s bug popping up or something similar
1:03:18
devon
Thanks, (format nil "~,6F" (coerce 3738064606000000/1000000 'double-float)) sure beats (let* ((n 3738064606071093/1000000) (s 1000000) (sn (* s n))) (multiple-value-bind (q r) (floor sn s) (format nil "~D.~6,'0D" q r)))
1:04:45
aeth
yeah, most of the time you use multiple-value-bind, you probably actually want multiple-value-call
1:15:03
pillton
Bike: Well, I think that documentation sharing thing is wrong. Imagine the surprises someone would have when using the programmatic interface to construct an environment. Secondly, an implementation may consider "compressing" code in fasls by sharing code objects.
1:20:24
devon
THX² Bike, aeth: (let ((n 3738064606071093/1000000)) (string= (format nil "~,6F" (coerce n 'double-float)) (let ((s 1000000)) (multiple-value-call #'format nil "~D.~6,'0D" (floor (* s n) s))))) => T
1:22:53
Bike
if you have a fraction already just do (format nil "~d~6,'0d" (numerator n) (denominator n))
1:25:33
aeth
devon: you wouldn't want string=, though, you'd want to find where the . is and then parse-integer and then divide the larger one by 10 until they're of the same base-10 length (but not quite beacuse you also have to take into account leading 0s) and then compare them.
1:27:30
aeth
Bike's version will prefix 0 for leading 0's to get it up to 6, but if the part after the decimal point is longer than 6, it will display them all. Afaik, the double float version will always cut it off after 6 decimal places after the decimal point. So the lengths could differ.
1:42:38
devon
Printing present-day universal times to µs, DOUBLE-FLOAT-EPSILON seems perilously close to dropping a low order bit. Perhaps it's time to define ~:F
1:52:33
devon
(format nil "~,,-6F, ~:*~,6,-6F" 1) => "1.0, 0.000001" ; is this a bug in CCL or a bug in the spec?
2:07:36
aeth
destructuring bind is most useful in macros. In fact, the lambda list of macros kind of builds it in to save a few levels of destructuring-binds.
2:08:36
aeth
a macro's lambda list might be (name (x y) &body body) and that's equivalent to it being (name parameters &body body) with a destructuring-bind in the macro of (destructuring-bind (x y) parameters ...)
2:11:20
aeth
So you're ensuring that a list matches some pattern, and binding the elements to that pattern. in (destructuring-bind (x y) (list 1 2) ...) x will be 1 and y will be 2. And (list) will be an error and (list 1 2 3) will be an error
2:12:43
aeth
The structure in destructuring-bind can be complicated like (x (y &optional z) (u (v &rest w)) &key a b c)
2:13:37
aeth
With multiple-value-bind you're just dealing with a bunch of values. so (multiple-value-bind (a b c) (values 1 2 3) (+ a b c)) => 6
4:35:30
beach
Good. Then, if you use ERC for IRC discussions, you can use Emacs abbrevs, so that when you type "tbh" or "idk", they will be automatically expanded.
4:36:21
beach
For instance, I have abbrevs for "Common Lisp", "Common Lisp HyperSpec", "Good morning everyone!", "(first) Climacs", "Second Climacs", "first-class global environments", "(admittedly small) family", etc. etc.
4:37:13
beach
Saves A LOT of typing, and makes it less necessary to explain to others what you are trying to say.
4:41:29
beach
I once calculated how many hours per month my abbrevs for writing email saved me. It was considerable. For some reason, I am one of the few people I know who use Emacs abbrevs. Strange to me.
4:43:49
White_Flame
because you're talking about full non-abbreviated text appearing in what you communicate
4:44:19
beach
White_Flame: It's a technical term. I guess you didn't know about them either. http://www.gnu.org/software/emacs/manual/html_node/emacs/Abbrevs.html
4:45:28
beginner_supreme
Is there a document anywhere describing the swank protocol that slime uses? Can't seem to find an official doc
4:46:52
beach
I also use Emacs abbrevs to fix some of my common typos. Like, my fingers seem unable to type "the", and they type "teh" instead. So I have an abbrev that "expands", the latter into the former. Same thing for "language" and "language".
4:55:52
devon
beginner_supreme: The swank protocol is so deficient, I'd not even look unless you plan to replace it.
5:02:27
White_Flame
I'm offering money to anybody who will refactor SLIME such that the elisp portion is hosted by swank, allowing multiple connections to different deployed versions simultaneously
5:03:51
White_Flame
with the initially emacs-side code simply being a bootstrap to connect & download elisp
5:06:29
shangul
but younger people don't understand what money is. they understand what ice cream and chocolate is
5:11:42
beginner_supreme
It seems the difference is that /msg cannot be seen by anyone else, but query is visible.
5:12:45
shangul
beginner_supreme, query in my client opens a new private window and optionally sends a message
5:15:04
jackdaniel
I don't know, but unless it doesn't work for him it is a valid answer ;-) /me moves along
5:23:24
jackdaniel
on the other hand, if you are interested in your own looping construct, I'd argue that building your macro upon DO is more readable
5:24:53
shangul
I'm leave and I'm not gonna lock the screen. because I know no one here would be able to work with i3 :D
5:25:52
flip214
minion: memo for Fare: https://bbt.legi.cash/ has a typo: "Solution: Extract Everything from a Same Spec" => "*the* Same Spec"
5:26:35
beginner_supreme
Loop is a dsl for looping/iterating. Quite useful, I haven't learned all the t