<iissaacc>
say i have an object containing a foreign pointer and i want to free it when the object is GC'd
<iissaacc>
if i do (defmethod sb-ext:finalize (obj some-class) (lambda () (free (foo-accessor object)))
<iissaacc>
from what i understand, this won't work because the finaliser refers to the object so neither of them will be GC'd
<iissaacc>
what is the correct way to do this? Hard to find examples
<iissaacc>
even a pointer (lmao) to some code where this is done would be helpful
<no-defun-allowed>
I don't think that's how FINALIZE works; here it's a non-generic function that takes an object, a finalizer function, and some other stuff.
<White_Flame>
the lambda holds a closure over the foreign pointer, not the object holding it
<White_Flame>
and yeah, you don't define a finalizer per class of object, but on each individual instance
<no-defun-allowed>
Supposing you had a standard-instance, you could do (defmethod initialize-instance :after ((object class) &key) (let ((handle the-handle)) (sb-ext:finalize object (lambda () (release handle)))))
<iissaacc>
right
<iissaacc>
I was just confused about the handle itself but i get the idea now. the handle is the pointer
<iissaacc>
thanks!
<White_Flame>
np
<iissaacc>
so i could do an :after initialize-instance method on my class and put the pointer creation and finalize stuff in there i guess
<iissaacc>
ah lol ignore that. just read the whole of no-defun-allowed's message
arpunk has quit [Remote host closed the connection]
<no-defun-allowed>
But you should probably use trivial-garbage to finalize; which has the same interface but is portable.
<iissaacc>
aha yes i just discovered that via google
EvW has quit [Ping timeout: 240 seconds]
<iissaacc>
shot (bro/sis)
<iissaacc>
another noob question - im rewriting some code from a library. I was redefining the functions like (defun library:function (my changes))
<iissaacc>
but this is probably a bad idea right? since it would change those functions for any code u have loaded in your image that uses them
<no-defun-allowed>
Yes, that is usually a bad idea, but if it's not possible to extend, you could get away with modifying it in a way that preserves the original behaviour.
<no-defun-allowed>
Or you probably should just have a modified copy of the original implementation in your packages.
<afidegnum>
hi, i'm tryinb to build a 2d graphics made of graphs, but i would like to save the outpout of those graphs in json. what CL library do you suggest ?
<bhartrihari>
heisig: Thank you.
ldb has joined #lisp
<ldb>
good afternoon
<aeth>
Interesting, I can't do ql:who-depends-on because org.borodust.bodge is 404ing and I can't temporarily remove org.borodust.bodge because if I do (ql:uninstall-dist "org.borodust.bodge") it also gets "Unexpected HTTP status for #<URL "http://bodge.borodust.org/dist/org.borodust.bodge/20200928222503/releases.txt">: 404"
ganjajim has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
IPmonger has quit [Quit: ZNC 1.7.5+deb4 - https://znc.in]
IPmonger has joined #lisp
<afidegnum>
ok thanks,
<aeth>
(I can just get rid of the dist's directory and everything seems to work, but it's weird that Quicklisp itself has no way to recover internally from this.)
<afidegnum>
for the 2d graphics, with parents/child shapes, clickable event .....
hendursaga has joined #lisp
hendursa1 has quit [Ping timeout: 240 seconds]
edgar-rft has joined #lisp
<afidegnum>
what's your suggestion for the graphics ?
IPmonger has quit [Quit: ZNC 1.7.5+deb4 - https://znc.in]
IPmonger has joined #lisp
<beach>
afidegnum: McCLIM, obviously.
<afidegnum>
beach: does McCLIM offers 2d graphics? the last time i checked, it offers just the GUI
<beach>
You must have checked sometime during the 20th century.
karlosz has quit [Read error: Connection reset by peer]
afidegnum has quit [Ping timeout: 264 seconds]
afidegnum has joined #lisp
iissaacc has joined #lisp
<saganman>
seems like there is no such a thing as function in lisp
<saganman>
I was going through debugger
<beach>
What?
<saganman>
defun defines a macro
<beach>
No.
<saganman>
it is a macro
<beach>
Defun IS a macro.
<saganman>
oh
<beach>
When a DEFUN form is evaluated, it defines a function.
<beach>
But DEFUN is a macro that essentially does (setf (fdefinition <name>) (lambda (...) ...))
<beach>
So LAMBDA is the function constructor.
<heisig>
LAMBDA is a macro, too :)
<heisig>
If anything, FUNCTION is the function constructor.
<beach>
Why did I just *know* that someone would say that.
<beach>
Not quite. (FUNCTION F) does not construct anything.
<beach>
So if you want to be picky, (FUNCTION (LAMBDA ...)) is the function constructor.
bocaneri has quit [Ping timeout: 240 seconds]
<heisig>
:D
<saganman>
"defun implicitly puts a block named block-name around the body forms (but not the forms in the lambda-list) of the function defined."
nicktick has quit [Ping timeout: 260 seconds]
<beach>
Sounds right.
Fare has joined #lisp
bocaneri has joined #lisp
<saganman>
ah, I misunderstood
ldb has quit [Ping timeout: 265 seconds]
<saganman>
it is kind of tricky
<saganman>
it is easy to misunderstand to have a macro that defines a function which is only evaluated?/compiled? only when the said function appears in the code
<saganman>
to a dumb guy like me, it seems like macro
<beach>
saganman: So that phrase means that if you type (DEFUN FF (X) (1+ X)), the macro expands to something like (SETF (FDEFINITION 'FF) (LAMBDA (X) (BLOCK FF (1+ X)))), so that you can say (RETURN-FROM FF ...) in the function body.
<saganman>
beach: oh, I see
jonatack has joined #lisp
<saganman>
beach: now I see it clearly
<saganman>
beach: your explanation is better than clhs
<beach>
The Common Lisp HyperSpec is not meant for users. It is a document for people creating Common Lisp implementations.
<beach>
There are several ways in which a function defined by DEFUN can come into existence. You can type the DEFUN form at the REPL, in which case EVAL is called to evaluate the form.
<beach>
You can LOAD a file containing the DEFUN form. Again, EVAL is called.
<beach>
You can first compile a file containing the form (that won't create the function), and then load the compiled file.
<saganman>
yeah, I have been doing that
<saganman>
I have been writing functions on one side, C-c C-c and use them in slime
<beach>
I was trying to elaborate on your remarks on how easy it is to misunderstand.
<saganman>
oh okay
bocaneri has quit [Ping timeout: 240 seconds]
sauvin_ has joined #lisp
dolphin5430 has joined #lisp
dolphin5430 has quit [Client Quit]
Inline has joined #lisp
jonatack has quit [Ping timeout: 272 seconds]
jonatack has joined #lisp
Oladon has joined #lisp
hapticFeels has quit [Ping timeout: 260 seconds]
rav3n has quit [Read error: Connection reset by peer]
cosimone has joined #lisp
scymtym has quit [Ping timeout: 240 seconds]
narimiran has quit [Ping timeout: 258 seconds]
met` has joined #lisp
space_otter has quit [Remote host closed the connection]
<met`>
In CL, is it necessary to user :accessor for a class slot to modify the contents internal to the data structure at the slot? E.g. if the slot contains a list, and I want to set/add/remove a value in the list, would :reader be sufficient (I'm not changing the thing that is stored in the slot, just its contents)?
<_death>
if the slot contains (list 'x) and you remove x, then you are changing the slot's contents, as it would become nil
<beach>
met`: Well, a list is a bad example.
<no-defun-allowed>
Generally, no, but "modifying" lists usually requires you to modify the place they reside in.
<met`>
Ah right, since the "list" is just the top cons cell, right?
<no-defun-allowed>
If it was another standard-instance or a vector, then it'd be doable, as those are modified by modifying values in those objects.
<beach>
met`: So if you modify only the elements of the list, and not its CONS cells, you are fine.
<_death>
you can always change slots directly by using (setf slot-value)
<no-defun-allowed>
Yes, or NIL, which can't be modified at all.
<met`>
OK. But in the case of an array or hash-table it should be fine?
<_death>
for vectors, it's the same story, unless you make sure you modify them in place (and perhaps make them adjustable)
<met`>
Can someone offer some perspective on how to think about "references vs values" in CL? From other languages I'm used to pointers for reference types (mostly) and other things being treated as values, and copied when e.g. passed as a function parameter. From reading some chapters in Practical Common Lisp I understood it as "everything is an object" in CL, which I guess would mean everything is treated as a reference?
dxtr has joined #lisp
<no-defun-allowed>
Yes, every object is one reference away in Common Lisp (and AFAICT, most other Lisp languages).
jonatack has quit [Quit: jonatack]
<_death>
Lisp is pass by value.. sometimes the values are references
<met`>
So how can I determine that the thing I'm passing is passed as a reference?
<beach>
met`: Assume it always is.
<beach>
met`: That's the semantic model.
<beach>
met`: The phrase "call by value" does not talk about the nature of the objects passed to a function. It only means that the arguments are evaluated before the function is applied.
<beach>
met`: So the values are references in Common Lisp.
<_death>
beach is right.. fixnums and characters for example may be copied (and hence may not be EQ to each other) but otherwise you can assume all values passed are references
<met`>
That makes sense.
<met`>
Thanks!
<beach>
met`: Also, "everything is an object" is an often repeated phrase, except that it is not true.
<no-defun-allowed>
Depending on who you ask, objects can be passed by value, like in C++, so that's not exactly equivalent; but it suffices to say nothing is copied in a way that you could observe it being copied (except for some things being tested with EQ).
<beach>
met`: A comment is not an object. A place is not an object.
<aeth>
met`: My thoughts on this is that nearly every object is a reference, it's just that immutable, optimizable things that can fit within a machine word (especially fixnums, but also probably characters, single-floats, etc.) are probably optimized away from actually being something like pointers internally. But this isn't visible to you directly, or you couldn't do that.
<beach>
met`: What I call "uniform reference semantics" is the only sane way of programming. Languages that distinguish between pointers and non-pointers quickly become way too complicated for application programming.
<met`>
In my case I want some object whose (read-only) state is shared between several implementers of another class, in a slot of that class. Would it then be enough to set the value of that slot in those class implementers to be the object whose state I want to be shared?
<no-defun-allowed>
My guess is C++ and Perl are the only frequently used "object oriented" languages that (can) pass by value.
<beach>
no-defun-allowed: Please don't use "pass by value" that way. It is not what the term means.
<_death>
no-defun-allowed: Lisp is pass by value!
<no-defun-allowed>
Yes, if you set them to the same object, they'll reference the same object; but I'm not sure what you mean by "implementers of another class".
<no-defun-allowed>
Right, I'll go revise what those words mean.
<phoe>
"pass by value" is a misnomer, should be "pass by copy"
<kinope>
Something that tripped me up until I 'got' it was that if you want to mutate a list of objects by destructively replacing a single element you need to target the `car` of the cons cell that contains the element as it is the cons cell that contains the reference to that object and the reference to the rest of the list.
<phoe>
in C++, passing by value means that you copy a thing and then pass it to a function - and you need to define what copying that thing means
<aeth>
It also means that for things around the boundary of copying vs. referencing, you can fall into the attitude of trying to microoptimize which to use
<phoe>
in CL, passing by value/reference/whatever means that you pass literally the same object - except the implementation is allowed to optimize for fixnums and characters and copy'em over
<beach>
phoe: Then they use it in a way that is not the widely agreed-upon meaning.
scymtym has joined #lisp
<phoe>
beach: sadly, the C++ people are the ones who define what is the widely agreed-upon meaning
<beach>
Though I guess "pass by value" could be distinct from "call by value".
<no-defun-allowed>
Yeah, looking up "pass by value" really only provides phoe's definition.
<aeth>
phoe: Not fixnums and characters. Numbers and characters. Various floating point types might count (especially short-float) and in theory there probably could be a "fixnum" of rationals that semantically could be made to fit in CL, it's just that no one bothers... unless I'm mistaken.
<beach>
phoe: Oh, that would be very sad indeed.
<beach>
no-defun-allowed: So then "pass by value" is different from "call by value". That's terrible.
<phoe>
aeth: that's what I meant by the implementation being allowed to optimize
<met`>
no-defun-allowed: I mean that the object I want shared is of some class A, and there is another class B with a slot to store a reference to an object of class A as read-only. Then each subclass of class B will store the shared object in the slot from the superclass and implement a method which operates on the state stored in the object of class A. Maybe there is a simpler way to achieve this...
<phoe>
that's in the cases where the objects are immutable so it's impossible to mutate one of them and observe the change elsewhere
<_death>
pass by value means that values are copied.. in this case the values are references to objects, so (defun swap (x y) (rotatef x y)) won't have an outside effect because the references are local, i.e. only the local bindings are modified
<phoe>
this doesn't really take sharedness into account
<met`>
phoe: Yeah that was what I was thinking of doing.
<met`>
Or actually no
refpga has quit [Read error: Connection reset by peer]
<phoe>
if you want a slot with a single shared value for all subclasses, :allocation :class on the slot is the way to go
refpga has joined #lisp
<no-defun-allowed>
Eugh, okay. In C++, not copying an object that is the argument of a function is arguably the exceptional case, as you have to put a & after a parameter type to get "a reference". And I think I misread about Perl; they have a "call by value" definition in their glossary, but there isn't a mechanism to achieve that.
<phoe>
(unless some subclass overrides the slot definition, at which point, they wanted it)
<met`>
phoe: Oh that's what I was looking for!
<phoe>
awesome
<no-defun-allowed>
beach: I recently got into a mess with a Java programmer, who had a different definition of "late binding" (which would probably be called dynamic dispatch elsewhere).
<met`>
phoe: So in that case I can store an object of the superclass, modify it, and see the changes reflected in each subclass?
<phoe>
actually the object will be stored when you create the instance
<phoe>
see :a (make-instance 'a)
__jrjsmrtn__ has joined #lisp
<met`>
So let's say I have 2 slots, a list and a hash table, in the superclass with :allocation :class. Can I update those slots and see the changes reflected in the subclasses as well?
_jrjsmrtn has quit [Ping timeout: 260 seconds]
<kinope>
met`: I think you could construct a cons cell with the object like (cons obj nil) then store the cons cell in the slot for each class you access the obj via (car (slot-value ...)) and can change the object via (setf (car (slot-value ...)))
<beach>
no-defun-allowed: I see. It is sad when people arbitrarily redefine established terminology.
<phoe>
met`: yes, that's the idea of class-allocated slots
<phoe>
update once, see the change everywhere
<met`>
OK, excellent. This should make things a lot simpler.
cosimone has quit [Quit: cosimone]
EvW has joined #lisp
<_death>
met: it will be the same as long as the subclasses don't say otherwise, e.g. by supplying a different initform or making the allocation :instance
<phoe>
but then the class in question will be explicly asking for it, so, it's not the problem of the parent
<_death>
phoe: right, it's just a nice feature to be aware of
<met`>
Makes sense. Thanks again to everyone.
<pve>
beach: Not sure if you mentioned it, but what *is* the definition of "call by value"?
<pve>
Oh, you did say, I see it now.. nevermind :)
AlexisTP has joined #lisp
Fare has quit [Ping timeout: 260 seconds]
Fare has joined #lisp
contrapunctus has left #lisp ["Disconnected: closed"]
contrapunctus has joined #lisp
Lycurgus has joined #lisp
refpga has quit [Ping timeout: 265 seconds]
<Lycurgus>
peccavi for replying to the new user the other day that defun didn return anything, at most i should have linked the hyperspec
<Lycurgus>
deserves comment because it makes me look stupid in re fp generally
<Lycurgus>
and this isn't a good place for idle chat
met` has quit [Quit: ERC (IRC client for Emacs 27.1)]
kaftejiman has joined #lisp
decentyousername has joined #lisp
orivej has joined #lisp
Fare has quit [Ping timeout: 260 seconds]
Fare has joined #lisp
achilles has joined #lisp
Lycurgus has quit [Quit: Exeunt]
Lycurgus has joined #lisp
refpga has joined #lisp
isBEKaml has joined #lisp
MichaelRaskin has quit [Ping timeout: 258 seconds]
AlexisTP has quit [Quit: Leaving]
<decentyousername>
In "Practical Common Lisp" chapter 20, Peter says the following in regards to multiple values: "The mechanism by which multiple values are returned is implementation dependent just like the mechanism for passing arguments into functions is. Almost all language constructs that return the value of some subform will "pass through" multple values, returning all the values returned by the subform. Thus, a function that returns the r
<decentyousername>
calling VALUES or VALUES-LIST will itself return multiple values-and so will another function whose result comes from calling the first function And so on."
<decentyousername>
I've read that section ten times and still don't understand what he means.
<decentyousername>
or what he's trying to explain.
<phoe>
(defun foo () (values 1 2 3))
<phoe>
(foo) ;=> 1 2 3
<phoe>
(defun bar () (foo))
izh_ has joined #lisp
<phoe>
(bar) ;=> 1 2 3
cosimone has joined #lisp
<decentyousername>
"Thus, a function that returns the result of calling VALUES and VALUES-LIST will itself return multple values and so will another function whose result comes from calling the first function and so on."
<decentyousername>
That's the part I don't get.
luis75 has quit [Ping timeout: 246 seconds]
<phoe>
this is the part that I explained
<decentyousername>
I've understood the part that almost all forms will return multiple values if the last form returns multiple values.
<phoe>
if FOO returns multiple values, then BAR will also return multiple values because its result comes from calling FOO
<decentyousername>
oh
<decentyousername>
thanks
<decentyousername>
phoe, you're my hero. :)
Codaraxis has joined #lisp
<phoe>
decentyousername: pleasure
<decentyousername>
The book should've put that example in there.
<decentyousername>
Maybe I'm just weird for not getting it.
<phoe>
don't worry about it
<phoe>
there's tons of things that sometimes require a different/good example in order to click
<phoe>
I get the same kind of mental reactions when trying to understand stuff
<decentyousername>
That's why I like the OpenBSD man pages, they often have great examples, which explain a lot more than ten paragraphs of text.
shifty has joined #lisp
Codaraxis_ has quit [Ping timeout: 240 seconds]
vaporatorius has joined #lisp
Lycurgus has quit [Quit: Exeunt]
Inline has quit [Ping timeout: 272 seconds]
EvW has quit [Ping timeout: 260 seconds]
refpga has quit [Read error: Connection reset by peer]
refpga has joined #lisp
isBEKaml has quit []
Fare has quit [Ping timeout: 260 seconds]
ex_nihilo has quit [Quit: Leaving]
nicktick has joined #lisp
niceplace has quit [Ping timeout: 272 seconds]
gxt has quit [Remote host closed the connection]
motersen has quit []
Lycurgus has joined #lisp
renzhi has joined #lisp
gxt has joined #lisp
orivej has quit [Ping timeout: 265 seconds]
_Ark_ has quit [Ping timeout: 264 seconds]
_Ark_ has joined #lisp
hendursaga has quit [Quit: hendursaga]
hendursaga has joined #lisp
gaqwas has quit [Remote host closed the connection]
ted_wroclaw has joined #lisp
shifty has quit [Ping timeout: 256 seconds]
refpga has quit [Read error: Connection reset by peer]
refpga has joined #lisp
TwoNotes has joined #lisp
jesse1010 has joined #lisp
cosimone has quit [Quit: cosimone]
izh_ has quit [Quit: Leaving]
refpga has quit [Read error: Connection reset by peer]
drot has quit [Quit: Quit.]
refpga has joined #lisp
jonatack has joined #lisp
<Xach>
I'm starting to think that the things that are broken today won't be fixed any time soon
<Xach>
(Maybe I'm attaching too much significance to no response to bug reports)
orivej has joined #lisp
<Lycurgus>
do you know of any other package that uses the gbbopen module system?
<Lycurgus>
(and i'd have thought with so many pkgs you would just arbitrate/cut off at will)
<phoe>
Xach: which things?
<decentyousername>
Are we talking about libraries in quicklisp?
<decentyousername>
O . o
achilles has quit [Remote host closed the connection]
mathrick has quit [Ping timeout: 240 seconds]
skapata has joined #lisp
ganjajim has joined #lisp
<phoe>
you mean the recent SBCL typing breakage?
<phoe>
s/breakage/warning on non-conforming code/
nullheroes has joined #lisp
ganjajim has quit [Remote host closed the connection]
arpunk has joined #lisp
Nilby has quit [Ping timeout: 260 seconds]
Bourne has quit [Ping timeout: 240 seconds]
refpga has quit [Read error: Connection reset by peer]
refpga has joined #lisp
gaqwas has joined #lisp
gaqwas has quit [Changing host]
gaqwas has joined #lisp
MichaelRaskin has joined #lisp
ganjajim has joined #lisp
bitmapper has quit [Quit: Connection closed for inactivity]
refpga has quit [Read error: Connection reset by peer]
refpga has joined #lisp
edgar-rft has quit [Quit: Leaving]
contrapunctus has left #lisp ["Disconnected: Replaced by new connection"]
contrapunctus has joined #lisp
contrapunctus has left #lisp ["Disconnected: closed"]
contrapunctus has joined #lisp
bitmapper has joined #lisp
Fare has joined #lisp
achilles has joined #lisp
thecoffemaker has joined #lisp
treflip has joined #lisp
alxplorer has joined #lisp
thecoffemaker has quit [Ping timeout: 258 seconds]
kaftejiman has quit [Read error: Connection reset by peer]
kaftejiman has joined #lisp
zacts has joined #lisp
alxplorer has quit [Remote host closed the connection]
Jeanne-Kamikaze has joined #lisp
thecoffemaker has joined #lisp
dxtr has quit [Ping timeout: 260 seconds]
random-nick has quit [Quit: quit]
EvW has joined #lisp
random-nick has joined #lisp
drdee has joined #lisp
drdee has quit [Remote host closed the connection]
narimiran has joined #lisp
cosimone has joined #lisp
rick-monster has joined #lisp
dra has joined #lisp
treflip has quit [Remote host closed the connection]
<Xach>
phoe: yeah
<phoe>
how many PRs were accepted and how many were not?
alxplorer has joined #lisp
achilles has quit [Remote host closed the connection]
alxplore_ has joined #lisp
alxplorer has quit [Ping timeout: 272 seconds]
cosimone has quit [Remote host closed the connection]
cosimone has joined #lisp
mfiano has joined #lisp
shka_ has quit [Ping timeout: 272 seconds]
Lycurgus has quit [Quit: Exeunt]
space_otter has joined #lisp
dra has quit [Remote host closed the connection]
ganjajim_ has joined #lisp
cosimone has quit [Quit: cosimone]
cosimone has joined #lisp
ganjajim has quit [Ping timeout: 240 seconds]
ganjajim_ has quit [Remote host closed the connection]
v0|d has quit [Ping timeout: 260 seconds]
cosimone has quit [Quit: cosimone]
bitmapper has quit [Quit: Connection closed for inactivity]
Inline has joined #lisp
<mseddon>
oh, is it not just me then? does anyone have links to opened issues on SBCL type nonsense that's appeared recently?
<mseddon>
(and perhaps it is just previously un-noticed nonsense that I was in a bad habit of, phoe?)
alxplore_ has quit [Remote host closed the connection]
<Xach>
phoe: I haven't seen many PRs at all
skapata has quit [Ping timeout: 272 seconds]
<phoe>
oh! I meant issues
<phoe>
I remember you making those
<phoe>
what are the stats?
<phoe>
mseddon: it's actually sense, just people were doing sloppy coding
Codaraxis_ has joined #lisp
Codaraxis has quit [Ping timeout: 240 seconds]
akoana has joined #lisp
alxplore_ has joined #lisp
zacts has quit [Quit: leaving]
gravicappa has quit [Ping timeout: 260 seconds]
cosimone has joined #lisp
<mseddon>
phoe: yeah, I didn't think it was SBCL, I thought I had suddenly become more stupid.
gravicappa has joined #lisp
<Xach>
phoe: hmm, not sure. i think i made 20 or 30. maybe 5 or so closed. not 100% sure.
<Xach>
(i can/should write a program to do that for me...)
<phantomics>
question: I often write loops like this: (loop :for x :in some-list :counting x :into xcount :do ...)
terpri_ is now known as terpri
<phantomics>
The xcount starts at 1 instead of 0, which can be annoying, is there an expedient way to make it start from 0?
alxplore_ has quit [Remote host closed the connection]
<phantomics>
Rather than writing something like (let ((xcount (1- xcount)) ...) inside the loop
<Xach>
phantomics: i'd like to help but don't really understand the question, sorry. what do you expect back from something like (loop :for x :in nil ...)?
<Xach>
or (loop :for x :in '(42) ...)?
<phantomics>
I want the xcount variable to start from 0 instead of 1
<mseddon>
phantomics: loop from?
bitmapper has joined #lisp
Bourne has joined #lisp
<Xach>
phantomics: that doesn't help me understand - what do you expect from my examples?
<phantomics>
Loop from works, but then if I want to loop over a list I have to use the :for variable to index from the list
<mseddon>
oh, right sorry. I get it, you want to :counting into xcount, but with xcount = 1 at the start of the loop?
<phantomics>
With xcount = 0 at the start of the loop
<Xach>
phantomics: what does the full loop form look like? you can have multiple independent iterations going
<phantomics>
Xach: what I'm asking is if there's a way to have a loop over a list or array, while counting into a variable that starts from 0 instead of 1
<jackdaniel>
i.e if there are five elements, to return four?
<pve>
phantomics: does it really start from 1?
<Xach>
phantomics: right - that's not clear enough for me. i guess i will stop trying to understand. good luck!
skapata has joined #lisp
<mseddon>
yeah the starting from 1 shouldn't happen.... xcount WILL start from 0.
<mseddon>
and for whatever reason, can't you subtract 1 at the end to fix it? :D
<phoe>
I usually do (loop for i from 0 for x in ...)
<phoe>
if that is what you want
<phantomics>
Here's a simple example: (loop :for x :across array1 :counting x :into acount :do (setf (aref array2 (1- acount)) x))
<phantomics>
See how I need to subtract 1 from the acount in order to assign the element in the array I'm looping over to the corresponding position in the other array
<jackdaniel>
phantomics: (loop for x across array for ref from 1 do (setf (aref array2 ref) whatever))
<jackdaniel>
counting is meant for something else
<phantomics>
phoe, that works, thanks
<jackdaniel>
s/from 1/from 0/
<jackdaniel>
ah, I've repeated what phoe said above
<jackdaniel>
nvm me then
<phantomics>
I'd forgotten I could loop starting from a number with no end point and also loop over another finite structure
<phantomics>
Appreciate it
<mseddon>
don't loop. iterate!
<mseddon>
loop is a magnificent non-extensible arcane mess.
<pve>
phantomics: but still, :counting did not do what you think it did.. i.e. what you were trying to do cannot be done with :counting
<phantomics>
I've seen iterate, thought it wasn't maintained anymore
<mseddon>
It hasn't been touched since like 1994 or something
<mseddon>
doesn't need to be. you can extend it.
<pve>
or, I guess if every x is non-nil, then it would actually work, but require the -1
shifty has joined #lisp
<phantomics>
Yeah, that was the problem, having to subtract 1
<mseddon>
like a lot of lisp libraries, it just.. stopped getting bug reports, so it's stable now
<mseddon>
but people still use it. if the users of that lib had an issue they'd get together, resurrect it, and fix it. Lisp operates on a rather longer timescale than other software.
skapata has quit [Ping timeout: 260 seconds]
defaultxr has quit [Quit: l8r]
dolphin5430 has joined #lisp
dolphin5430 has quit [Client Quit]
scymtym has quit [Ping timeout: 260 seconds]
skapata has joined #lisp
heisig has quit [Ping timeout: 265 seconds]
alxplorer has joined #lisp
renzhi has quit [Ping timeout: 260 seconds]
kaftejiman_ has joined #lisp
alxplorer has quit [Ping timeout: 240 seconds]
kaftejiman has quit [Ping timeout: 272 seconds]
kaftejiman__ has joined #lisp
kaftejiman_ has quit [Ping timeout: 240 seconds]
kaftejiman__ has quit [Remote host closed the connection]
kaftejiman__ has joined #lisp
sts-q has quit [Quit: ]
sts-q has joined #lisp
TCZ has joined #lisp
TCZ has left #lisp [#lisp]
jw4 has quit [Read error: Connection reset by peer]
jw4 has joined #lisp
arpunk has quit [Ping timeout: 260 seconds]
manicennui has joined #lisp
arpunk has joined #lisp
cosimone has quit [Ping timeout: 272 seconds]
srhm has joined #lisp
alxplorer has joined #lisp
narimiran has quit [Quit: leaving]
alxplorer has quit [Ping timeout: 272 seconds]
galex-713 has quit [Ping timeout: 272 seconds]
cosimone has joined #lisp
galex-713 has joined #lisp
scymtym has joined #lisp
cosimone has quit [Remote host closed the connection]
cosimone has joined #lisp
ggole has quit [Quit: Leaving]
decentyousername has quit [Ping timeout: 265 seconds]
gravicappa has quit [Ping timeout: 272 seconds]
cosimone has quit [Quit: cosimone]
TwoNotes has quit [Quit: Leaving]
edgar-rft has joined #lisp
ted_wroclaw has quit [Ping timeout: 240 seconds]
alxplorer has joined #lisp
alxplorer has quit [Ping timeout: 272 seconds]
alxplorer has joined #lisp
ted_wroclaw has joined #lisp
Lycurgus has joined #lisp
renzhi has joined #lisp
arisun has joined #lisp
arisun has left #lisp [#lisp]
gaqwas has quit [Ping timeout: 256 seconds]
shifty has quit [Ping timeout: 240 seconds]
EvW has quit [Ping timeout: 240 seconds]
<aeth>
eh, if it's something like iterate, then not being touched since 1994 is a bit concerning
<aeth>
there's always room for optimizations, unless the extensibility prevents optimizations
Inline has quit [Ping timeout: 272 seconds]
EvW has joined #lisp
pve has quit [Quit: leaving]
Inline has joined #lisp
EvW has quit [Ping timeout: 260 seconds]
Inline has quit [Remote host closed the connection]
Inline has joined #lisp
jibanes has quit [Ping timeout: 240 seconds]
jibanes has joined #lisp
joast has quit [Ping timeout: 260 seconds]
EvW has joined #lisp
edgar-rft has quit [Quit: Leaving]
random-nick has quit [Ping timeout: 240 seconds]
alxplorer has quit [Remote host closed the connection]
rixard has quit [Ping timeout: 272 seconds]
alxplorer has joined #lisp
hiroaki has quit [Ping timeout: 256 seconds]
amb007 has joined #lisp
alxplorer has quit [Ping timeout: 272 seconds]
igemnace has quit [Quit: WeeChat 2.9]
arpunk has quit [Read error: Connection reset by peer]
<drmeister>
Using Common Lisp to interactively manipulate the shape of a molecule.