freenode/#lisp - IRC Chatlog
Search
16:49:36
pjb
Ukari: also, notice how in (let ((zero 48)) (+ zero 4)) it doesn't matter whether zero is a constant variable or not: we can see it LEXICALLY that we are not mutating the bingin, and the compiler knows it too, so it can eliminate the variable and inline the value.
16:50:45
pjb
Try it: (declaim (optimize (space 3) (speed 3))) (disassemble (compile nil (lambda (d) (let ((zero 48)) (+ zero d)))))
16:50:46
Ukari
if use a (funcall return-48) instead of 48, literals way can't use (funcall return-48)'s value twice if I don't wan't funcall return-48 twice
16:52:01
pjb
Constant variable values must be known at compilation time, so they may be inlined by the compiler.
16:52:29
pjb
Ukari: Look, the point is that defconstant is a very strange and very specific operator that just doesn't do what you think it does.
16:52:55
pjb
Already, the name "constant VARIABLES" should give you a hint you're in Alice Wonderland territory.
16:53:48
pjb
Ukari: so lexically, things are know at compilation time, or they don't qualify for "lexical".
16:54:06
pjb
the value returned by (function return-42) is not a lexical value, because it cannot be known by the compiler.
16:54:49
pjb
(unless some very specific cases, but few CL compilers implement the global analysis that would allow them to know).
16:55:42
pjb
Ukari: perhaps you would want to consider a macro or a compiler-macro to deal with those forms, instead of just a binding?
16:57:34
Ukari
maybe it is a mistake for me to use defconstant as a compare target to what i need, what i need is not literal constant because it can't assign to some stuff in runtime
16:58:30
Ukari
what i need is a immutable let, it could assign once, assign to some stuff in the runtime, then it couldn't change anymore
17:01:09
Bike
i don't think it's hard to imagine a let binding that would have setqs of the variable to be a compiler warning or error, regardless of one's understanding of physics.
17:01:45
pjb
Either you write a assignment inside the scope, or you don't. And this is written textually, in space, so it is known of all eternity whether you did it or not.
17:02:29
pjb
Bike: sure, but then you want to change the compiler. As a user, you can do that with writing your own IMMUTABLE-LET macro and do the code walking to check.
17:04:50
Ukari
though let is analysis by compile in space, but the assignment between stuff to it is actually happens in runtime
17:16:40
Ukari
the compiler knows the reference or address or pointer, but not know the value store in address
17:16:41
pjb
This gives you a run-time check. Perhaps sbcl could also validate it at compilation time.
17:20:23
beach
Ukari: There is, for example, a compiler optimization technique called "constant propagation" that takes this information and replaces all references to the variable by the literal.
17:21:23
beach
Speaking of which, I have always claimed that even application programmers should know about compiler design. I have seen so many application programmers write silly code because they have an incorrect model of what the compiler does.
17:22:43
Bike
though "the compiler never knows about or does any optimizations ever" is a new attitude for me
17:25:19
Ukari
If i remember correctly, in python, if there is a array a = [1, 2, 3, 3]. use id(a[2]) and id(a[3]), you could find it returns a same address where stores the only one 3
17:25:45
makomo
beach: i agree. in general, regarding usage of any interface, i think that programmers should be aware of how the underlying implementation works, or at least have an idea how it works
17:27:01
makomo
beach: for me, using an abstraction shouldn't mean that you're ignorant about the details. it should mean that you half-know how it works, but don't assume anything, i.e. you're intentionally avoiding relying on anything that's implementation-defined
17:28:10
Bike
fuck, id is an address-of function. that's a weird builtin for a language like python to have
17:28:20
beach
makomo: I think I understand. The "silly code" I was referring to typically avoided abstractions because of some idea that the compiler would generate slower code then.
17:28:58
makomo
beach: ah i see. i guess it's not directly related, but i think it's an interesting thought/approach anyway
17:30:24
Ukari
in let example, complier gives address and no need to know what stores in address because what stores in address is not sure in runtime
17:30:57
Bike
Ukari: Lisp doesn't have some weird semantics where you can redefine what 3 is at runtime. if you write (let ((x 3)) ...) x will be 3, as is intuitively obvious.
17:33:09
mfiano
I'm sorry for spreading misinformation...I was completely wrong. It's lists that are implemented as arrays, rather than linked lists.
17:33:10
beach
I am intrigued by this idea that the compiler should not optimize code even if it can because it is not its "duty".
17:33:21
Ukari
well, Bike, but the optimization technique trick only happens in some case can't prove that all stuff's value which assign by let are certein in compile time
17:36:05
jackdaniel
it could be certainly useful for testing (being able to disable certain optimizations, so you can for instance examine output with only one optimization being active), but it is a different story
17:37:46
makomo
half of everything in this world would be much easier if people just used consistent and proper terminology
17:39:04
jackdaniel
new ideas emerge from chaos, made-up terminology may spawn new ideas (by triggering metaphores) etc, don't discard the brilliance of mistakes
17:42:29
makomo
in fact, alex stepanov, the designer of C++'s STL, named std::vector after CL's vector
17:45:04
jackdaniel
non-optimizing compilers may be also useful for producing result code which is meant to be read by a human - as a first draft (and tweaked after that manually), but that's very rare I suppose
17:51:00
makomo
beach: "When a generic function or any of its methods mentions &key in a lambda list, the specific set of keyword arguments accepted by the generic function varies according to the applicable methods."
17:51:04
specbot
Keyword Arguments in Generic Functions and Methods: http://www.lispworks.com/reference/HyperSpec/Body/07_fe.htm
17:51:35
makomo
"The set of keyword arguments accepted by the generic function for a particular call is the union of the keyword arguments accepted by all applicable methods and the keyword arguments mentioned after &key in the generic function definition"
17:54:41
makomo
or would that whole section of the standard only apply in the case when we have a &key in our GF
18:10:35
littlelisper
i want to get the modification time of a file. is there any library for it? i googled but no help
18:21:28
makomo
if i'm writing a DSL and want my macros to be indented nicely, what are some general tricks or ways to structure these macros to make this happen
18:22:14
makomo
"here" is where is how i want the process code to be aligned, "not-here" is what i don't want
18:24:47
_death
I assume you're asking about the editor (emacs+slime) indenting it.. there's trivial-indent, but for more complicated macros you could patch cl-indent or otherwise write elisp code to do it
18:42:11
_death
you can import specific _symbols_ from a _package_ using :import-from in your defpackage form
18:46:02
pjb
(defparameter *my-fun-package-foo* (list (function sin) (function car) (function cos)))
18:46:29
pjb
(defparameter *my-fun-package-bar* (list (elt *my-fun-package-foo* 0) (elt *my-fun-package-foo* 2)))
18:46:48
pjb
So you have "imported" the first and third function from *my-fun-package-foo* into *my-fun-package-bar*.
18:47:15
pjb
CL packages only deal with symbols, not with functions or variables or types or whatever the symbol is used to name.
18:49:09
pjb
littlelisper: on the other hand, you may not care if the symbols used to name your function also name types or slots or variables or whatever.
18:49:56
pjb
It also helps that global variables are special, therefore they are named with *stars-around*, and functions usually no. (even if some functions may be named with one or two postfix stars, like, f, f* and f**).
18:50:44
pjb
On the other hand, it occurs often that you have both a type and a function using the same name: (typep (vector 1 2) 'vector) (typep (list 1 2) 'list) etc.
18:56:13
_death
(defpackage "AI" (:use "COMMON-LISP") (:export "THINK")) (defpackage "PERSONALITIES" (:use "COMMON-LISP") (:import-from "AI" "THINK") (:export "THINKER")) (in-package "PERSONALITIES") (defun thinker () (loop (think)))
19:00:25
warweasle
_death: I was hoping the singularity would hit today. I don't trust people to run things anymore.
19:03:10
_death
warweasle: the last time I hoped for a singularity event was when I waited at some hospital queue (for a routine check) while the secretaries went superslow
19:04:07
MichaelRaskin
_death: let me assure you that it is in fact possible to intentionally program AI to maintain unacceptably slow speed of the queue
19:08:14
aeth
If I compile a random program, I can tell you without looking at anything but htop if it's C++ or not.
19:16:08
aeth
I'm not sure why people say SBCL takes a long time to compile or otherwise list its compile time as a disadvantage. (1) you only ever see that when you update QL and (2) it doesn't take very long, and this is even with only one core being used
19:16:50
aeth
Well it's generally either very quick or an infinite loop bug, but, yes, you can put anything in compile-time
19:18:09
aeth
Bike: you generally only see everything being compiled when you ql:update-all-dists afaik.
19:20:48
aeth
Bike: The only thing that seems to be noticably slow in the entire compilation process is cl-sdl2 and that's probably because it uses autowrap
19:22:04
Bike
the level of confidence you put into your assertions really doesn't match the evidence behind them
19:27:08
aeth
Just under 3 seconds to build the largest thing that I've written in CL, which is about 7k lines of code, and it has one slow file because of an elaborate data structure.
19:30:59
aeth
Let's say 2.8 and let's say it's directly related to LoC. 7k in 2.8 seconds is 2.5k a second. (/ 60d3 2.5d3) would then be 24 seconds. Actually sounds fairly plausible.
19:31:48
aeth
My computer could be twice as fast as yours and/or your files could be more elaborate at compile time.
19:36:49
scymtym_
i halved SBCL's ironclad compile time some time ago. and this weekend, stassats halved it again
19:39:19
aeth
Of course, kloc/s probably isn't the best measurement when you can do so much at compile time.
21:38:47
pjb
varjagg: (setf (sexp-file-contents "user-token.db") '(("pjb" . "DEADFACE") ("varjagg" . "12345678")))
21:43:52
pjb
Again, depending on the number of processing acessing the data, the size of the data etc.
21:45:44
aeth
When CL is popular enough, it might even add s-expressions to its storage next to JSON and XML and whatever else.
21:48:58
aeth
PostgreSQL is definitely the way to go, though. Perhaps via postmodern. https://github.com/marijnh/Postmodern
21:50:28
aeth
mySQL is for performance or ubiquity, SQLite is if you want to embed a SQL database, and noSQLs (including random CL-based storage systems) aren't a good fit for the problem.
22:16:16
aeth
It's possible that they make it require nickname registration to prevent being hit by the spambot that floods freenode from time to time
22:34:18
edgar-rft
noobly: #emacs was locked for users with non-registered nicks a while ago because too much spam.
23:11:04
MoziM
is there an elisp function that can change all the values of a property in a nested plist? this is an example of what i'm trying to navigate through, i want to set all :background properties to "black" http://termbin.com/9j5o
23:44:59
karlosz
it seems that converting to hir takes 2 out of the 10 seconds it takes to compile alexandria