freenode/#lisp - IRC Chatlog
Search
15:45:27
crsc
Nice to know. I installed vlime yesterday and it works fine for me. Hopefully he will come back in the future.
16:22:13
makomo
hah, hi there :D, i watched your (old?) stream about running lisp on an arudino and solving some PE problems
16:22:21
sjl
I generally use my initials for more tech-related things like github/irc and longer names for non tech stuff like photos
19:26:59
makomo
if i have a file with, in order, some defclasses, some defuns and in the end some defconstants whose value forms create instances of the previously introduced classes
19:27:30
makomo
are the defconstants not evaluated only once everything before in the file has been evaluated?
19:28:01
ebdreger
makomo: classess and functions not available until done processing file, unless you wrap with ... what phoe said.
19:28:23
Shinmera
"An implementation may choose to evaluate the value-form at compile time, load time, or both."
19:31:06
ebdreger
or use an alternative that checks equality using something a little more permissive
19:31:12
makomo
is there some kind of a summary/description of the different phases that lisp has in one place?
19:33:15
Shinmera
load-time happens during the loading of a file, after the file has already been compiled, or a form has been compiled
19:33:34
phoe
(also macroexpansion-time that runs during compile-time whenever a macro needs to be expanded)
19:35:03
makomo
so loading a file entails reading the file, compiling the file and executing the file then?
19:36:05
ebdreger
(it doesn't make life simpler that the compile and load phases are often blurred together by one's environment)
19:36:08
Shinmera
loading will cause either one of the following phases to happen: (read compile load execute) or (load execute)
19:38:04
makomo
yeah :^(, that's why it would be nice if the whole thing was described somewhere in one place
19:38:05
Shinmera
COMPILE will perform (compile load), though here the load is only relevant for load-time-value.
19:38:24
ebdreger
rule of thumb that makes life a little easier: don't use COMPILE or EVAL without good reason (usually dynamically-generated code that can't be created any other way)
19:40:03
phoe
ebdreger: I actually use compile in places like (compile nil (lambda (foo) (frob foo bar)))
19:40:07
makomo
so, if i had for example, a defun, followed by a top-level (+ 2 2) expression, followed by another defun
19:41:11
Shinmera
makomo: in the source file case, forms are processed in order and go through all phases one by one
19:42:03
makomo
Shinmera: oh, so there's an actual ordering. i thought that there might not be after what i've heard now (limiting ourselves to source files)
19:44:18
Shinmera
One of the puzzling things to understand is that each phase can cause evaluation to happen
19:44:37
Shinmera
So, even if we speak of "load-time", there's probably just code being evaluated during it.
19:45:46
Shinmera
Right. If you want to peek into the insanity of it all, read Fare's blog post on eval-when. http://fare.livejournal.com/146698.html
19:48:07
ebdreger
there also are fun tidbits like sb-ext:save-lisp-and-die that can help you distinguish the stages
19:48:10
Shinmera
Don't let it confuse you too much. Most of what you'll ever need to know is that some top level forms might not take effect until later, so you have to wrap them into (eval-when (:compile-toplevel :load-toplevel :execute) ..) to make their effects available at all times.
19:49:12
Shinmera
And you should know about load-time-value to emit constants without them needing to be FASL-dumpable.
19:49:40
makomo
i usually don't like using something without understanding the details of how it works. sometimes that's good, sometimes it leads me into a rabit hole that's hard to get out of
19:52:36
Shinmera
Anyway, I'm not the best to talk to about this either-- I feel unsure about the exact workings of some parts. beach and Bike might know better.
19:55:47
minion
Xach, memo from fiddlerwoaroof_: I added a new Makefile to the repository that should work without any external dependencies. Just Make -f Makefile.minimal mkapp
19:58:45
phoe
one of my most recent frustrations with the standard is related to the naming of simple-arrays and simple-vectors
20:00:02
sjl
it is a little odd that vectors are one-dimensional arrays, but a one-dimensional simple-array is not necessarily a simple-vector
20:03:42
Shinmera
Sure, but point being if you have an immediate type you don't need to tag check, making it even faster.
20:04:28
pjb
makomo: in any case, it is not useful to use defconstant to bind instances to variables.
20:04:32
phoe
yep, but simple-vectors are built around the idea of *not* having element-type information.
20:05:46
pjb
makomo: the point of defconstant is to tell the compiler that it may generate the value as immediate value (thus making copies of the value) in the binary instructions. Therefore it's only useful for values that can be immediate in the native instruction set, ie. basically integers and characters.
20:39:36
borei
is it possible to define setf for entire object, not for particular slot, but entire object ?
20:44:58
aeth
Although it's confusing to have a setf function without an equivalent regular function and I'm not sure what a regular function would do by default.
20:45:10
pjb
slots can contain immutable data (that can be copied), or references to immutable data (the reference can be copied, thus sharing the immutable data), or references to mutable data (that may or may not be copied, thus sharing or not sharing the mutable state), or also the may contain derived data or cached data, that is computed and updated "automatically".
20:45:35
pjb
borei: therefore we cannot give you a generic method to copy the slots from one instance to another: you have to provide it yourself!
20:46:31
phoe
you can't modify whole objects in-place - you can only modify references. and places are references.
20:47:59
pjb
phoe: No, war is over, the USA won, and Europe is vasal. We can be raped anytime, and this occurs all the time
20:48:02
aeth
borei: If you write an accessor that only works on one value you can use with-accessors just like a CLOS accessor, and then you could do (setf matrix 5.0d0) while really calling the accessor
20:48:26
aeth
borei: If you write an accessor that works on more than one value, you'll have to manually use symbol-macrolet yourself, but the same principle applies
20:48:52
aeth
(technically the setf accessor really has one more value than it looks like it has, though, the new value)
20:50:00
jmercouris
pjb: "Middle English, borrowed from Anglo-French, borrowed from Medieval Latin vassallus" - it's kinda french :P
20:51:51
jmercouris
there's a lot of french speaking countries that refuse to learn english, don't feel so bad :P
20:52:20
jmercouris
i like the people that suggest that we'll all be speaking chinese, like population of speakers is the only criteria for adoption of language, nevermind the impossible writing and pronounciation
20:52:56
aeth
The heart of with-accessors or something similar to it is (let ((thing (gensym))) `(let ((,thing ,object)) (declare (ignorable ,thing)) (symbol-macrolet #|fancy stuff|#) ,@body)))
20:55:31
pjb
jmercouris: Chinese, not because of the population, but because of the economic might. The USA is falling fast.
20:56:55
aeth
pjb: That doesn't take into account that French was still the lingua franca after France stopped being the superpower, during pretty much the entire era of the British Empire's dominance
20:57:41
aeth
English afaik really became the world language after 1945, with the primary countries of the competing languages of French and German in ruins
21:00:25
jmercouris
Russian was a language forced onto all of their satellite countries, I wouldn't say it was "competing" so much as "coerced"
21:00:54
jmercouris
as much as english sucks, it's an easy language to speak incorrectly and still be understood, the same cannot be said of most other languages
2:09:17
madpengu
(defparameter *a* (list 1 2 3)) (defparameter *b* (list 4 5 6)) (defparameter *c* (append *a* *b*)) (setf (first *a*) 55)
2:15:22
madpengu
Okay, figured, append is only allowed to reuse the last structure, not just any one of them
2:20:08
pjb
madpengu: append is not destructive, but the result shares the last argument, so if you mutate the result, it could be destructive!
2:20:56
pjb
(let ((a (list 1 2 3)) (b (list 4 5 6)) (c (list 7 8 9))) (tailp c (append a b c))) #| --> t |#
2:21:00
madpengu
I was just confusing about what is reused, it seems only the last structure, no the first one.
2:21:52
pjb
Notice that this is what lets you use append to build a dotted list: (append '(1 2 3) 4) #| --> (1 2 3 . 4) |#
2:23:15
dmiles
(otherwise indeed it may have been nice to have had it resue the first structure to save space)
2:23:44
pjb
(let ((a (list 1 2 3)) (b (list 4 5 6)) (c (list 7 8 9))) (tailp a (nconc a b c))) #| --> t |#
2:29:00
pjb
madpengu: you can also use (com.informatimago.common-lisp.picture.cons-to-ascii:draw-list (cons '(1 2 3) 4))