libera/#commonlisp - IRC Chatlog
Search
4:12:29
rdrg109_
[Q] How to correctly use backtick to get the value of the value of a variable? Here's a minimal example: (let* ((a 100) (i 'a)) <<do something with i to get 100>>). I've tried the following, but I can't get 100 (i.e. the value of a)
4:12:50
rdrg109_
I asked this question in #emacs, but I thought that maybe more people in #commonlisp are familiar with this topic.
4:13:55
beach
That's by design. If you could, the compiler couldn't do much to optimize the code that refers to such variables.
4:15:26
beach
There is nothing magic about backquote. It is just a reader macro that expands to a form containing macro and/or function calls. So if you can do something with backquote, you can do it with ordinary forms.
4:16:07
beach
And since you can't get the value of a lexical variable using ordinary forms, you can't do it with backquote.
4:47:27
phantomics
Is there an expedient way to write a (loop) form that will iterate over either a list or vector? Like (loop for i A B) where A is across if B is a vector or in if B is a list?
4:52:35
contrapunctus
phantomics: IIRC the `iterate` and `for` systems have generic iteration clauses
4:52:42
beach
ACTION thinks perhaps his utterances don't get through to the channel, because it feels like speaking to a black hole.
4:52:51
Nilby
phantomics: It's possible to write such a loop macro, but back in the olden days, the idea that you would implictly double the size of your code and add type testing to a very common usage probably seemed like a bigger deal that it would be now. That ‘elt’ has very different different performance can even still be trouble.
4:54:23
phantomics
Wouldn't use it if it's not supported across CLs, I'll write the loop another way
4:55:03
beach
... and I prefer the singular form since the loop variable can hold only one value at a time.
4:56:22
Nilby
in Dylan, which in some ways is a succesor to CL, they made a complicated iteration protocol with which you could make such a loop work out better
4:58:28
beach
Maybe Dylan was the result of yet another person being absolutely sure of the reason why Common Lisp is not more popular, and thus designing a language without that particular flaw, so absolutely certain of that language taking over the world.
5:00:17
kakuhen
phantomics: note that the ITERATE library is reasonably portable, and you can also extend it; I have successfully used it on SBCL, CCL, ECL, and ABCL
5:00:18
Nilby
david moon apparently still belives infix is better, and wrote a rational for it in his PLOT language
5:01:12
Nilby
using dylan and CL for a long time, i still think prefix is better. the dylan macro system feels like a mess
5:01:18
kakuhen
there's also some goodies that you just can't get with LOOP (or, I'm not clever enough to figure out how), such as NEXT-ITERATION
5:01:42
phantomics
I understand iterate's format is more normative for Lisp, will be worth checking out at some point
5:04:05
edgar-rft
beach: after your answer to rdrg109 followed a discussion on #emacs where it turned out that rdrg109's idea was rather quirky, he's probably overthinking his idea right now
5:17:06
beach
edgar-rft: Thanks! I still find it extremely impolite to 1. Ask a question. 2. Get an answer, and then 3. Not acknowledge that an answer was given. But then I was once told to basically "go away, because that's IRC for you dude" or something to that effect.
5:34:46
pillton
Does anyone have reading material that covers creating abstractions for sets of things? e.g. a set of images or a set of image sets. The set itself will have properties and each item in the set will have properties. I am finding it tedious to implement wrappers around existing data structures and I am looking for better ways.
5:44:19
hayley
Nilby: The specification of forward-iteration-protocol wouldn't pass the critique in <https://plover.com/~mjd/misc/hbaker-archive/Iterator.html> as the iteration "state" object can be modified by iterating.
6:01:55
Nilby
hayley: while i despise C++ iterators, i still think baker is wrong on that. for performance reasons, but also stateless control is clumsy for certain things, e.g. iterating over lists in parallel, with variable stepping. it seems unlikely to totally dissuade programmers from using iterators, even if they're just integers. anyway, the iteration protocol should be mostly for implementaion of iteration, and it's usually better to use a
6:03:21
hayley
A functional "iterator" (as in, we have an object the caller steps) still allows for parallel iteration. And stepping with different strides isn't much of an issue.
6:08:42
jackdaniel
beach: dylan was initially created by apple, so (unlike i.e clojure) it was probably designed by a group of professionals, similar to common lisp
6:09:36
jackdaniel
(unlike clojure in a sense, that clojure was designed by one person to scratch an itch if I understand correctly)
6:10:46
hayley
That is my definition of an "iterator". The difference is that calling (say) the NEXT function on the iterator means the previous iterator cannot be re-used, with the Dylan iterator protocol. I assume this restriction is due to allowing "non-functional" iterators where the iterator object is modified in-place.
6:11:13
jackdaniel
n.b, and there we are, with clojure being magnitude more popular than both dylan and common lisp together ,)
7:36:20
scymtym
Nilby: in SBCL, the LOOP clause for sequence iteration actually uses the iteration protocol for non-list non-vector sequence. and likewise for sequence functions
7:43:37
scymtym
Nilby: i'm pretty sure SBCL's protocol was inspired by Dynlan's but i can find the citation right now
7:44:19
scymtym
a hint at least: https://github.com/sbcl/sbcl/blob/d35ad6f9bee212499cb827fec3195bf2064c10a2/src/pcl/sequence.lisp#L365
8:13:36
pve
Hi! Could a method have more than one qualifier? Like (defmethod compute :foo :bar (x y) ...)
8:15:38
pve
yep, I actually saw that, but became unsure since I don't think I've ever seen multiple qualifiers
8:16:29
beach
But you can define your own method combination, and then it can take any number of qualifiers.
9:58:43
Krystof
Nilby: SBCL's sequence protocol is ~15 years after CMU was doing Dylan interoperability. But, see section 1.3 of https://research.gold.ac.uk/id/eprint/2344/1/sequences-20070301.pdf
11:04:33
contrapunctus
First I found MGL-PAX, then 40ants-doc, and now https://github.com/shinmera/documentation-utils
11:06:35
contrapunctus
Damn, this is amazing. I was thinking about something like this very recently - describing each argument and return value in a structured way.
11:16:26
Shinmera
Pretty sure documentation-utils does something different from the other ones you listed.