freenode/#lisp - IRC Chatlog
Search
16:59:42
Shinmera
My advice would be to investigate other means of processing your data (stream oriented) so that you don't need that much memory to begin with.
17:32:35
asarch
One stupid question: From this chapter: http://www.gigamonkeys.com/book/macros-standard-control-constructs.html
17:33:13
asarch
In the DO section: "As with the variable definitions in a LET, if the init-form is left out, the variable is bound to NIL. Also as with LET, you can use a plain variable name as shorthand for a list containing just the name."
17:34:22
beach
asarch: It means you can write either (let ((x nil)) (let ((x)) ...) or (let (x) ...)
17:34:30
dlowe
it means like you can do (let ((foo nil)) ...) and (let ((foo)) ...) you can also do (let (foo) ...)
17:41:18
beach
asarch: Let me take advantage of your question to point out the (moral, not semantic) difference between (let ((x nil)) (let ((x '()) and (let (x).
17:41:27
beach
In the first case, you initialize x either to a Boolean false value or to some default value. It is fine to use x before assigning to it and to (conditionally) assign to it before using it, but you would not unconditionally assign to it before using it.
17:41:32
beach
In the second case, you initialize x to the empty list. Again, it is fine to use x before assigning to it and to (conditionally) assign to it before using it, but you would not unconditionally assign to it before using it.
17:44:23
beach
asarch: Imagine (let (x y) ... Is that the same as (let ((x y)) or the same as (let ((x nil) (y nil))?
17:46:46
beach
asarch: Because of what I wrote. It could either mean both X and Y to NIL, or binding X to Y.
17:48:52
shrdlu68
The second form would not be possible in a let form that took the form (let (x 1) (y 2)
17:49:05
_death
beach: it wasn't meant as an advice, just an attitude perhaps meant for someone more experienced ;)
17:49:52
shrdlu68
You'd have to always use (let (x nil) explicitly. But as _death points out, it's entirely possible to create such a let macro.
17:53:58
stacksmith
Alexandria's when-let compromises: if you only have a single binding, you can (when-let (a whatever) ...), and if you have multiple, it looks like (let).
17:56:57
stacksmith
The 'founding fathers' could have gone with a lambda-list-like syntax: a name or a list containing a name and an initializer... (let (a b (c 9)) ...)
18:01:51
stacksmith
_death: I am not sure how useful they are - I always wind up with the second form needing unless, for some reason :)
18:28:13
Shinmera
Rational operations typically require reduction after the actual operation, which is likely expensive
18:42:20
asarch
In "(do ((n 0 (1+ n)) (cur 0 next) (next 1 (+ cur next))) ((= 10 n) cur))", is next part of the DO statement?
18:45:27
_death
asarch: cur is zero in the first iteration, and then receives the value of next at the end of the iteration
18:48:27
asarch
Ok. Let's go by parts. Accordingly with the book, the general form of DO is: (do (variable-definition*) (end-test-form result-form*) statement*)
18:49:48
asarch
In this expression "(do ((n 0 (1+ n)) (cur 0 next) (next 1 (+ cur next))) ((= 10 n) cur))", the (variable-defition*) part is "((n 0 (1+ n))", right?
18:52:22
Bike
((n 0 (1+ n)) (cur 0 next) (next 1 (+ cur next))) are the variable definitions. (= 10 n) is the end-test-form. (cur) is the result forms.
19:02:50
oleo
well if the one of the variables is not what you return, but you rather accumulate in the body or so....that can be done yes
19:06:37
stacksmith
Can anyone think of a reason why SBCL compiles an extra check against structure layout when one would do? Given a structure mytype, an expression (if (mytype-p foo) 1 2) results in a double conditional, with two different things compared to <SB-KERNEL:Layout for MYTYPE>?
19:08:17
stacksmith
I cannot decipher the indirections. In one case it's RAX after some loadings, in the second case, an indirect DWORD PTR [RAX+17] in my case.
19:12:07
_death
such a question should include the form, its disassembly, your expectations and the deviation
19:14:47
stacksmith
_death: true enough; however, in absence of inheritance what would _ever_ be a reason to check type more than once? It is more of a philosophical question - or a puzzle if you will, as in can you think of a scenario where checking exactly twice makes sense?
19:17:25
stacksmith
I've run across this a few times, leading me to veer away from dispatching on type and storing redundant type data in structures when optimization is necessary... But I just cannot think of a reason why...
19:18:56
stacksmith
Bike: it compares something against the 'layout' twice, and there is an extra conditional
19:21:22
Bike
i'm looking at a similar diassembly. it looks like it compares with the layout, then jumps to a return if the comparison succeeds.
19:22:49
stacksmith
With (speed 3)(safety 0)(debug 0)? I have 4 conditional jumps and 5 labels in my disassembly of (defun xtest (obj) (declare (optimize (speed 3) (safety 0) (debug 0))) (if (ldesc-p obj) 1 2))
19:24:43
_death
stacksmith: the first comparison may be for the object being of the exact type mytype (the usual), the second comparison may be needed for proper subtypes..
19:26:11
stacksmith
that's what I thought, but there are no subtypes, and SBCL knows that. I can see CLOS checking just in case something changes, but structs...
19:27:36
stacksmith
Bike: true, but structs are not generally too forward-looking in my experience, unlike CLOS.
19:28:07
Bike
many kinds of redefinition are forbidden, but that doesn't change the fact that you could define a subtype
19:34:48
_death
"The sb-ext:freeze-type declaration declares that a type will never change, which can make type testing (typep, etc.) more efficient for structure types."
20:01:12
Josh_2
Does CLX let me get the position of my mouse in my current x session or only in one created with CLX?
20:01:34
flip214
Shinmera: stream oriented isn't possible, some early data might need fixing up when the later items are processed...
20:08:13
Xach
Josh_2: when X was being specified, CL was considered very much a peer of C and other potential client languages
20:31:47
Josh_2
So I downloaded CLX with quicklisp, and slime is saying that (clx:open-display .. ) isn't recognized. What's the package name?
20:52:20
Josh_2
When (open-display .. ) asks for host it's asking for my computers hostname or localhost I assume?
20:53:50
Xach
Josh_2: in the past I've used (xlib:open-default-display) to have it try to connect to the display set in $DISPLAY
23:13:51
borei
trying to find more or less detailed documentation on VOPs, but failed. Only couple articles. Any hint is more then welcome
2:35:43
White_Flame
although that's equivalent to (+ 3 3), so having a function there that's called doesn't make a lot of sense
2:37:58
White_Flame
asarch: you can either evaluated (defun foo ...) right in the REPL, or you could edit a source code file by inserting that DEFUN with emacs/SLIME and load it in. Both methods will immediately have your function available to call.
2:38:51
White_Flame
and you don't need to type in uppercase. The reader auto-upcases text internally when reading symbols
2:39:29
White_Flame
there's also the #clnoobs channel, which might be more appropriate for this level of question
2:42:58
White_Flame
you can just do a plain (let ((a 1) (b 2)) (format t "~a ~a~%" a b)) to scope in Lisp
2:44:23
asarch
Because I could do in the first 5 lines of my code: (defun foo () ...) (foo), and then later in the line #1000 recall foo: (foo)
2:45:03
White_Flame
you can call (foo) after (defun foo ...) has been executed, and you can manually mung with ordering
2:45:52
White_Flame
JS is a very, very weak language when it comes to scoping & controlling source code ordering
2:46:02
White_Flame
so you really don't have to worry about a ton of stuff that JS makes you worry about
2:46:33
White_Flame
(of course, later versions of JS are cleaning things up, but your examples are kinda oldschool JS)_
2:47:15
White_Flame
so a lot of "How do I do <some JS thing>?" will be answered with "You don't need to"
4:02:13
JuanDaugherty
on the debian vs slime, the time came when all the debian cl things were completely removed
4:13:06
krwq
hey, why does this code produce warning that *foo* is undefined? (defun foo () (defvar *foo* 0) (incf *foo*))
4:14:49
Bike
the defvar is not run at compile time, so the compiler doesn't know that *foo* is special as it compiles the incf
4:15:57
Bike
if you need a special variable that's only used in one place, you don't need to use defvar, either
4:17:44
krwq
scenario is following: I want a macro which makes a non complicated place thread safe, i.e.: (defun pformat (control-string &rest args)
4:20:05
Bike
(with-gensyms (lock) `(let ((,lock (load-time-value (bt:make-lock)))) (bt:with-lock-held (,lock) ,@body)))
4:20:58
Bike
now, if you just had (let ((,lock (bt:make-lock))) ...), that wouldn't work since it would make a new lock for each time you execute it
4:21:17
Bike
load-time-value is a special operator that makes its operand be evaluated only once, when the fasl is loaded, and reused thereafter
4:21:42
krwq
Bike: I assume this will work also when I just load a file (ok if it redefines it then)
4:23:01
Bike
but then, if you're just loading the macro could be expanded more than once, giving it different gensyms anyway
4:23:49
Bike
(incf x) is just (setf x (1+ x)), it doesn't modify the value of x, just changes what it's set to