<mrcom>
aeth: That sounds like market opportunity knocking. "Aeth's House of Discount Standards" -- "All the Meat and None of the Fat"
gko has quit [Ping timeout: 252 seconds]
gko has joined #commonlisp
<mrcom>
Differentiated pricing, too. "$ - You hit SUBMIT, We number it" ... "$$$ - N layers of premium review, consideration, and correction, and the extra special "$$$$ - Peer reviewed by a genuine member of the House of Lords"
<pranav>
zoravur: Would you like to ask a question about the repl session that helps us understand where you're struggling exactly?
<zoravur>
The closest comparison I can draw is lvalues and rvalues in assignment in the case of `setf`, and references in the case of `pop`
awlygj has joined #commonlisp
<mrcom>
zoravur: Perhaps it would help you get your head around it if you drew the CONS boxes with the arrows pointing to "1", "2", etc.
<mrcom>
(I'm assuming you've seen the CONS cell boxes thing.)
<zoravur>
Yes, why is it that when I (defvar a '(1 2 3)) and assign (cdr a) to a variable b, is it that when I pop b the original list remains unchanged. I have seen the cons cell boxes thing yes, it's similar to a linked list?
<pranav>
zoravur: https://novaspec.org/cl/f_pop See the notes at the end of the page which describe the behaviour of POP in terms of SETF.
<ixelp>
pop | Common Lisp Nova Spec
<aeth>
a -> [1 | -]-> [2 | -]-> [3 | \]
<aeth>
Now what is b doing?
<pranav>
zoravur: POP modifies a place; `(cdr a)` names a place within the structure of the list in `a`, whereas `b` names a place that is not part of the list in `a`.
<zoravur>
It seems like `pop` is updating a reference to the value b instead of b itself, and creating a new variable creates a new reference to (cdr a)
<zoravur>
so you get b -> [2 | -]-> [3 | \]
<pranav>
Both the places named by `(cdr a)` and `b` get modified by POP, but only in the former case does it mean modifying the list `a`.
<zoravur>
is pop a macro?
<zoravur>
google tells me yes
<pranav>
Yes
<pranav>
The Hyperspec would tell you that as well.
<paulapatience>
You can also expand pop to see what it is doing.
shawnw has joined #commonlisp
<zoravur>
okay I am trying to read this (prog1 (car place) (setf place (cdr place))) in novaspec but it is confusing me. How does the expand thing work? I tried `(macroexpand-1 (pop b))` but it's just running the function
<pranav>
zoravur: Are you using SLIME or SLY? Both have interactive ways to expand macros.
shawnw has quit [Ping timeout: 252 seconds]
<zoravur>
I am using sbcl
<zoravur>
!?
<pranav>
Are you using the raw sbcl repl from the terminal?
<zoravur>
just with `rlwrap`
<zoravur>
but that's for command history so nothing to do with expansion
<pranav>
Anyway, you'd wanna use (macroexpand-1 '(pop b))
<zoravur>
ah I thought macroexpand-1 was itself a macro, but it's just a function. ironic
Guest71 has joined #commonlisp
<zoravur>
okay this is hurting my brain. Point though is pop has different behaviour with (pop (cdr _)) and (pop _). So that means that I shouldn't necessarily expect them to be the same
<pranav>
You shouldn't expect (cdr a) and b (right after (setf b (cdr a))) to name the same places, even though they may evaluate to the same value.
danse-nr3 has joined #commonlisp
luis has quit [Server closed connection]
luis has joined #commonlisp
jonatack has quit [Ping timeout: 244 seconds]
jmiven has quit [Quit: bye]
jmiven has joined #commonlisp
edgar-rft_ has joined #commonlisp
cage has joined #commonlisp
cage has quit [Excess Flood]
cage has joined #commonlisp
edgar-rft has quit [Ping timeout: 258 seconds]
green_ has quit [Ping timeout: 260 seconds]
danse-nr3 has quit [Quit: nap]
decweb has joined #commonlisp
rtypo has joined #commonlisp
Akbar-Birbal has left #commonlisp [Disconnected: Replaced by new connection]
Akbar-Birbal has joined #commonlisp
<younder>
Seems a functional style of consing would hurt your brain less. That (setf b (cdr a)) seems questionable to me
lucasta has joined #commonlisp
<beach>
zoravur: You are also modifying literal data, which is undefined behavior.
<beach>
zoravur: And you are using variables A and B without first defining them.
<beach>
zoravur: That too is undefined behavior.
<beach>
zoravur: Like people said, (POP (CDR A)) means roughly (SETF (CDR A) (CDR (CDR A))) so it modifies the list structure of the list that is the initial value of A, and (POP B) means (SETF B (CDR B)), so it modifies the value of the variable B, but not the list that is its value.
<beach>
zoravur: If you want to do things right, do (DEFPARAMETER A (LIST 1 2 3)) instead of (SETF A '(1 2 3))
<beach>
zoravur: And even better, use earmuffs on special variables, so (DEFPARAMETER *A* (LIST 1 2 3)).
<beach>
zoravur: I also recommend you join #clschool for questions like this. People hang out there specifically to answer newbie questions like this one.
<beach>
zoravur: POP has to be a macro. If it were a function, (POP B) would not be able to modify the value of B. The semantics of functions require the arguments to be evaluated before the function is applied, so if POP were a function, it would receive the value of B but it would know nothing about where that value came from, so it could not modify value of B.
<beach>
zoravur: But again, these are elementary questions, better suited for #clschool.
<zoravur>
Sorry, i didn't know there was a separate channel for noob question. I will shift my questions there
<beach>
Great!
<McParen>
beach: (pop b) can modify b is b is a clos object, for example. that restriction is only for lists.
<beach>
Not so.
<beach>
It can modify the object that is the value of B, but it can not give B a different value. That is, if POP were a function.
<McParen>
okay.
<beach>
McParen: And there is no distinction between lists and other objects.
<beach>
McParen: If the value of B were a list, then a function that receives that list as a value can definitely modify the list.
<ixelp>
(defun f (x) (pop (cdr x))) => F and (defparameter *a* (list 1 2 3)) => *A* and (f *a*) => 2 finally (values *a*) => (1 3)
<beach>
McParen: The distinction is huge, but it is hard to explain in words, yes.
<McParen>
it took me quite a long time to understand that you can modify stuff with function calls, but only certain stuff, not everything.
<beach>
I don't think that's a good way of describing it. But I see what you mean.
Akbar-Birbal has left #commonlisp [Disconnected: Replaced by new connection]
<McParen>
and finding out what you can modify and what you cant is basically trial and error since i've nowhere seen it explained.
Akbar-Birbal has joined #commonlisp
<beach>
I am sorry to hear that that's how you see it. What you can modify is perfectly clear according to the semantics, which I refer to as "uniform reference semantics".
<pranav>
McParen: See Hyperspec 5.1.2 Kinds of Places
NotThatRPG has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
jon_atack has joined #commonlisp
amb007 has quit [Read error: Connection reset by peer]
amb007 has joined #commonlisp
mrcom is now known as the-woodwork
jonatack has quit [Read error: Connection reset by peer]
the-woodwork is now known as mrcom
NotThatRPG has joined #commonlisp
NotThatRPG has quit [Read error: Connection reset by peer]
NotThatRPG has joined #commonlisp
ym has joined #commonlisp
mwnaylor has joined #commonlisp
edgar-rft_ is now known as edgar-rft
ym has quit [Ping timeout: 252 seconds]
King_julian has joined #commonlisp
<prokhor>
urgent question: how do i access files in a vm in a backup file? the template has become obsoloete so i can not restore it :(
<bike>
er, is this a lisp question?
greaser|q has quit [Changing host]
greaser|q has joined #commonlisp
greaser|q is now known as GreaseMonkey
pve has quit [Quit: leaving]
<aeth>
From a low level point of view, you could view everything in CL as references (but you can't access the pointers or reference locations directly) to objects on the heap except when it can be small enough to be optimized (e.g. fixnums... and this is why you can't access it directly! is a single-float on the heap or not? in 32-bit probably, in 64-bit probably not) or when you request otherwise (declaring
<aeth>
dynamic-extent, but most declares, including that one, are requests that can be denied).
mgl_ has quit [Ping timeout: 252 seconds]
<aeth>
Or, rather, small and immutable. Fixnums are both. Single-float may or may not be small enough.
akovalenko has quit [Read error: Connection reset by peer]
akovalenko has joined #commonlisp
King_julian has quit [Ping timeout: 272 seconds]
King_julian has joined #commonlisp
NotThatRPG has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
NotThatRPG has joined #commonlisp
wacki has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
yitzi has quit [Remote host closed the connection]
xlymian has quit [Ping timeout: 276 seconds]
King_julian has quit [Ping timeout: 244 seconds]
xlymian has joined #commonlisp
skeemer has quit [Ping timeout: 252 seconds]
spdegabrielle has joined #commonlisp
xlymian has quit [Read error: Connection reset by peer]
shawnw has joined #commonlisp
alternateved has quit [Remote host closed the connection]
shka has quit [Ping timeout: 248 seconds]
zoravur has joined #commonlisp
zoravur has quit [Client Quit]
char has joined #commonlisp
JuanDaugherty has joined #commonlisp
amb007 has quit [Ping timeout: 252 seconds]
ec_ has quit [Remote host closed the connection]
ec has joined #commonlisp
JuanDaugherty has quit [Ping timeout: 252 seconds]
NotThatRPG has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]