libera/#commonlisp - IRC Chatlog
Search
18:45:58
Guest74
so I've noticed some problems with pipes, or vertical bars, when typing at the repl. If you make a mistake while typing you're screwed because of 'unbalanced parantheses'. Is this a paredit only thing, or does it happen with other modes that provide the same functionality.
18:46:07
lisp123
(like :test). Also equal DOES mean a lot of different things - is it the same object? is it an 'equivalent' object, is something based on a particular criteria for equality
18:46:17
engblom
phantomics: I rewrote it into a macro so I do not need to quote stuff in the function call. I now have this https://pastebin.com/1pzn6EzE
18:47:08
engblom
phantomics: Even thou macroexpand-1 shows a correct form, it complains that the plist I pass to it is undefined.
18:47:32
lisp123
Guest74: bind 'paredit-mode' to a hotkey so that you can quickly switch between paredit mode on and paredit mode off
18:48:10
engblom
Oh, now I noticed where my mistake is, I still have build-form even thou the macro got another name
18:48:21
Guest74
It happens in paredit, i'm wondering if it happens in other modes that provide the same functionality.
18:49:38
Guest74
I don't remember what any of those packages are called, but i'm guessing somebody here must use something besides paredit.
18:50:38
lisp123
I don't find any of the other ones as good as paredit to be honest (tried them a few times)
18:52:05
phantomics
Hi engblom, it appears this macro is supposed to work recursively but macros don't work like that, functions do
18:52:40
phantomics
You want to use the recursive function inside the macro, use (labels) to set up the recursive function within the macro
18:53:06
hobo
White_Flame: sorry for the late response, but yes, I remember telnetting into Valheru MUD from my high school's windows box in the library that only had telnet on it.
18:55:03
lisp123
Paredit? Good luck contacting the author, he is a mysterious legend. Here is his website: https://mumble.net/~campbell/
18:56:39
lisp123
It's like god, he gives you the bible / religious document of [insert language], but doesn't want to deal with mortals raising issues ;)
18:57:22
lisp123
I tried contacting him one to no luck. You probably have a better chance of forking the repo and adjusting it to your needs
18:58:28
hobo
and it turns out I was mistaken. It actually enters a CRLF, writes message, and then rewrites the prompt.
18:58:35
Guest74
I'm not concerned about my needs, i'm concerned how my stuff works on everybody elses machine.
18:59:27
lisp123
Then you should definitely fork it, amend it to your requirements and include that as part of your delivery mechanism
19:05:43
White_Flame
hobo: huh, that's an interesting compromise, but it would break the input-buffering clients like mudlet or tf
19:18:27
engblom
If I have something like ("a" (:A 1 :B 2) "b" (:A 3 :B 4)) I get nothing with (getf my-plist "a")
19:19:21
engblom
rain3: The key will actually be a string that I will have to use. Keywords are converted to upper case.
19:20:29
White_Flame
there is reader conversion, but (intern "FooBar" (find-package "KEYWORD")) => :|FooBar|
19:20:56
White_Flame
however, that means that you'll also need to search the plist with an interned symbol, too
19:26:56
White_Flame
but, if it makes more sense to keep things strings, then use alists instead of plists
19:35:18
White_Flame
and it's easier to use plain list operators on alists than plists, because on alists there's a 1:1 correspondence between list entries and alist mappings. With plists it's 2:1 and can get funky
19:36:04
White_Flame
depending onthe size of your tables, you might want to consider hashtables as well
19:36:13
engblom
White_Flame: Is it possible to nest alists, like I have done in the pasted example? Or would you keep the inner list as a plist?
19:36:40
White_Flame
but key=>value is just data. the outer container doesn't care what's inside the value slots
19:37:28
White_Flame
however, I think the one advantage that plists have is that you can (setf (getf ...) ..), which I don't think you can do as simply with alists
19:38:10
engblom
White_Flame: The lists will be around 100 pairs long, so hastables are probably overkill. Besides, the lists are actually are actually handwritten in a configuration file and then read in by read-from-file
19:38:57
White_Flame
that handwritten form doesn't need to be the canonical format at runtime, though. You can read it in as an easy-to-hand-edit list, and then store it in another format, too
19:44:13
engblom
doplist from alexandria seems to be able to loop over a plist with string keys, so it should be easy to convert it to a hash table by inserting each key and value.
19:47:29
engblom
Clojure has this nice syntax for hash maps: {:key1 1, :key2 2}. Is there something similar I could directly read in from a file with common lisp?
19:49:49
yitzi
There are also various packages which define a reader macro character for hash tables. Or you could just define your own.
21:25:09
pjb
engblom: I already explained to you that you that plists used only EQL to compare the keys!
21:26:29
pjb
engblom: (let* ((plist '("a" (:A 1 :B 2) "b" (:A 3 :B 4))) (keys (loop for (k) on plist by 'cddr collect k))) (loop for k in keys collect (getf plist k))) #| --> ((:a 1 :b 2) (:a 3 :b 4)) |#
21:29:11
pjb
but note that (let ((k 42)) (eq k k)) may return nil or t depending on the implementatioin!
21:30:04
pjb
so while you can find the actual string used as keys, and find them with get or getf (they use EQ to compare the keys), if the keys are numbers, you can't even be sure to be able to retrieve them!
21:31:06
pjb
engblom: if you want to be able to specify the test function, then use a-lists! assoc and rassoc take a :test argument!
21:51:52
engblom
pjb: I think hash table will be the best solution as then I only once need to specify the test function and the code will be easier to read.
21:53:49
pjb
engblom: but equal or equalp are very coarse. Good for strings, but for other keys (eg. vectors or arrays), you may want a more specific test.
22:05:22
engblom
pjb: As alexandria:plist-has-table does not recurse into the lists deeper in, it is not a problem. All the first level keys will be strings.
0:53:50
pdietz
IMO i's a good idea to look in alexandria or other such utility libraries (I like serapeum) for these sorts of things.
5:25:39
beach
phantomics: What would be the point of breaking backward compatibility for the very minor convenience to a very small number of users of Common Lisp?