libera/#commonlisp - IRC Chatlog
Search
17:09:56
Guest74
it is inconsistent as in you have to type it. If you want to use autocomplete to see all greek symbols you can't.
17:13:45
phantomics
In terms of improvements to CL, I might like to see some functions that do similar things condensed into a single function that takes options to work in different ways
17:13:59
Guest74
apropos doesn't help when you're typing. Already have a function to display all keysyms in a language set.
17:16:06
_death
if you want to move just a bit to the right in the complain-fix scale, I guess there's submitting an issue
17:19:50
beach
phantomics: Common Lisp is not going to change. And such changes would not necessarily be possible to reach consensus with anyway. Do you have an example of what you mean?
17:21:08
jackdaniel
well, it changed a few times already. i.e defpackage local nicknames extension, but this is a backward-compatible change
17:22:44
dbotton
jackdaniel except I backed out local nicknames from my project since LW doesn't support it
17:24:35
jackdaniel
it must be said that phoe was very active in the area of prompting people to implement this api back when only sbcl, abcl and ecl had it
17:34:01
phantomics
beach: For instance, condensing eq, eql, equalp etc. into one function that takes a third parameter to determine the type of comparison
17:35:36
Guest74
Does the amount of symbols in the keyword package present any problems the larger it gets? mines already over 5000
17:36:08
phantomics
At that level it shouldn't be a problem, but really large numbers of keywords can be a problem
17:37:22
phantomics
There are DOS attacks involving JSON libraries like Jonathan that create keywords for JSON keys, you can exhaust the heap by sending a service like this big JSON strings with thousands or millions of different keys
17:37:24
engblom
Is it somehow possible to create a macro inside of function, in the same way as you can with label define functions inside of a function?
17:41:09
engblom
ACTION is still trying to figure out how to make a recursive setf so that (rsetf some-plist 1 'one :b) would set change some-plist from ('one (:a 2 :b 1) 'two (:a 3 :b 4)) into ('one (:a 1 :b 1) 'two (:a 3 :b 4)).
17:41:30
engblom
ACTION is still trying to figure out how to make a recursive setf so that (rsetf some-plist 1 'one :a) would set change some-plist from ('one (:a 2 :b 1) 'two (:a 3 :b 4)) into ('one (:a 1 :b 1) 'two (:a 3 :b 4)).
17:59:18
phantomics
If the structure you're changing will only ever by a plist, you can write a macro that builds (setf (getf (getf plist 'one) :b) X)
18:01:41
phantomics
(defun build-form (value keys &optional output) (if (not keys) `(setf ,output ,value) (build-form value (rest keys) `(getf ,output (first keys)))))
18:02:17
phantomics
That's more or less how you do it, you pass the key path in as the second arg to that function, and the name of the list i.e. some-plist as the third arg
18:02:41
phantomics
(defun build-form (value keys &optional output) (if (not keys) `(setf ,output ,value) (build-form value (rest keys) `(getf ,output ,(first keys)))))
18:09:51
engblom
phantomics: They will always be plists but of different depts. Some might be only two levels, some 3 or more levels.
18:10:27
phantomics
Then that function will build the nested (getf) you need, it works recursively with any number of keys
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.