libera/#commonlisp - IRC Chatlog
Search
10:43:38
moon-child
has slime any affordances for reader macros, or must I modify its source code if I want it to be able to handle them?
10:49:07
moon-child
that's the main thing. Syntax highlighting and autocompletion may also bend a bit, but I do not care so much about those
11:53:29
ns12
What is the meaning of backslashes within a string? For example, (format t "1\2\3") prints "123". What happened to the backslashes?
11:54:34
phoe
escape your backslash with a backslash to get a literal backslash in your string, like "1\\2\\3"
11:56:45
ns12
So "\1" is equivalent to "1"? So a backslash only has meaning for some characters that come after it?
11:56:51
jackdaniel
escape your backslash with a backslash to get a literal backslash to avoid metaphorical backslash from the formatter
12:08:00
ns12
I see. So this means that it is not possible in Common Lisp for "\" to have value "\" without somehow modifying the reader?
12:12:51
ns12
Is it possible to modify how strings are read? For example, could I modify the string reader to use | instead of \ as one of the special characters?
12:18:19
moon-child
(set-macro-character #\" (lambda (s c) (loop until (char= #\" (peek-char nil s)) for c = (read-char s) if (char= c #\|) collect (read-char s) else collect c finally (read-char s) (return ...))))
12:18:49
ns12
Oh wait. I actually know how to do that. Sorry. I didn't realize that I've actually done that before.
12:23:55
jackdaniel
ns12: I was poking fun of multiple words 'backslash' in phoe explanation, and added "metaphorical backslash from the formatter" - it should be backlash.
12:27:16
jackdaniel
from numerous quotes on McCLIM website my favourite is "McCLIM, the stuff that really boring dreams are made of." by Andy Hefner
12:31:15
mfiano
As Shinmera pointed out the other day, "enough" means that an implementation not supporting it would prevent the usage of a good portion of the library ecosystem nowadays.
12:32:56
mfiano
Which is even more of a reason to adopt it. It was one of |3b|'s more popular ideas apparently :)
12:34:38
ns12
On the subject of package renaming. Suppose I am using a third-party library with a long package name (e.g. com.example.the-most-amazing-library) and I get tired of typing the long name whenever I use a function from that library. Is :local-nicknames *the* way to rename the package?
12:36:40
moon-child
I see a bunch of 'ISSUE's in that proposal. Curious: is there a proper spec somewhere?
12:37:27
ns12
Thank you all. I learned something extremely useful today that I would not have gotten by reading the standards.
12:37:48
mfiano
moon-child: The SBCL implementation/manual is the spec others go by, as it's what 3b contributed to.
12:38:22
moon-child
phoe: 'someone needs to do it' well, that's kind of The Problem in general, ne? :P
12:40:32
ns12
It's not yet supported in CLISP: https://portability.cl/#trivial-package-local-nicknames
12:42:07
moon-child
hmm, portability.cl claims sicl does not support them, but afaik it does. Not that it makes sense to have a sicl column at all, but
12:44:28
mfiano
Shinmera: About your blog post: I find it funny that I often use PLN to make a _longer_ nickname of your "V" nickname for "VERBOSE", so that it doesn't conflict with my preferred "V" nickname for vectors :)
12:53:21
moon-child
(admittedly the latter is a somewhat less practical venture than the former. But)
13:21:27
phoe
CLISP is no longer an implementation I consider supportable because it hasn't released in a decade even if it's possible to build it from source nowadays
13:23:36
phoe
Mezzano and SICL and JSCL too, although they are incomplete and/or otherwise troublesome to use
13:24:08
phoe
JSCL, largely incomplete; SICL, incomplete but highly modular; Mezzano, because of its requirements
13:24:40
mfiano
phoe: Good thing you used read-eval here for LW: https://github.com/phoe/trivial-package-local-nicknames
13:43:24
madnificent
Is there something like equalp that can be specialized using a generic function. Either by standard or by convention?
13:44:59
phoe
tl;dr "equality" is a poorly specified term so there can't be a one-size-fits-all solution
13:46:50
phoe
and if you do, then either (defun foo= (foo1 foo2)) or (defgeneric eqv (x1 x2)) is probably the way to go
13:49:15
madnificent
phoe: Glancing over that article, I find that to be a very fragmenting statement.
13:50:31
madnificent
Scanning through this article, it makes sense. But that does mean that every library will start defining their own equality predicate, rather than having something that could be shared and discovered.
13:51:57
phoe
madnificent: yes, and then you'll write your own custom equality predicates as the user of those libraries based on the APIs exposed by those libraries
13:52:27
phoe
equality in an impure language is surprisingly complex and one can't magically make it simple
13:52:40
madnificent
So we lack a common terminology or wiring across libraries. Even though imperfect, we don't have a shared language due to this.
13:54:13
madnificent
I would have expected there to be some library that exposed some method that said something like "if it's read the same way as it's written, then this should yield truthy". I could implement that and reuse a common language.
13:54:58
madnificent
Now I'll expose an equality operator somewhere in my library for my special case and I get to define my special rules. Rules which, in many cases, would conflate with other people's rules.
13:55:32
madnificent
phoe: Assuming you print readable objects. But it's just an example. Nothing in particular that interests me in this case.
13:56:23
madnificent
moon-child: right! When I define my own, I'll make haphazard decisions on these things and I'll likely be wrong. If a library would have defined a few terms, I could have chosen one and my decision would have been better than what I'll do now.
13:57:01
moon-child
madnificent: but this is the point we are trying to make. There are not wrong decisions, but _appropriate_ ones; and what is appropriate is highly contextual
13:57:08
madnificent
I'm now going to define an equivalence function. My definition will be full of holes (because I'm thinking of this one case). It will work. The next person reading it will probably wonder about some of the holes I didn't catch.
13:57:57
phoe
if I (defclass foo () (bar baz)), what does it mean for two objects of class FOO to be equivalent?
13:58:36
madnificent
phoe: Exactly! A library can give some common descriptions. I can implement one of them and we gain a shared vocabulary!
13:59:37
madnificent
I agree that an implementation is hard to shove forward. The Semantic Web has a similar issue with definitions of what is the same and what is related. But having some form of definition helps create a shared language and at least we can combine datasets in a valuable way. Perfect? Nope, but we *can* roll our own.
14:00:06
madnificent
I'm not looking for a library with an implementation, but rather one with a set of possible specifications.
14:00:49
madnificent
I agree that providing a generic implementation is ... not at all better than what we already have in CL.
14:01:08
phoe
the issue is that you can't specify equivalence ahead of time no matter how your generic function is going to look like because there's plenty of possibilities to define *distinct* equivalence classes for all sets of objects
14:01:29
phoe
so you'd need to have something like (eqv x1 x2 ...) where ... specifies the "sort" of equivalence that you are looking for
14:01:49
madnificent
phoe: and a library defining generic functions could describe in its docsctrings various options. Common sorts of equivalence.
14:02:49
splittist
I think the library talk is a red herring; I can see the attraction of a shared vocabulary. e.g. slotwise-equivalent, read/write-equivalent
14:03:00
phoe
and so we're reimplementing DEFGENERIC EQUIVALENT-OBJECT from http://www.nhplace.com/kent/PS/EQUAL.html
14:03:10
madnificent
As an example. OWL specifies owl:sameAs (https://www.w3.org/TR/owl-ref/#sameAs-def). Although vague, it provides a shared vocabulary.
14:04:57
phoe
madnificent: then (DEFGENERIC EQUIVALENT-OBJECTS (X Y INTENTIONAL-TYPE)) should work for a starting point
14:05:02
madnificent
moon-child: this is the exact same problem. There are two URIs, like memory locations, and they mean the same thing. owl:sameAs says "hey, these are actually the same". Not perfect, but a sort of description that puts people in the same place.
14:06:34
madnificent
moon-child: Also, that's not how the semantic web works. You can reuse an identifier no problem.
14:07:43
phoe
madnificent: make a decent test suite and I won't need to be confident in you since I'll be able to be confident in the tests :D
14:09:06
mfiano
I think such a library would be subject to combinatorical explosion very quickly though.
14:09:14
madnificent
phoe: I don't think you can provide tests for something that has no implementation. At least no valuable ones. Ideally someone has researched equality in depth and has created categories of equality.
14:09:57
madnificent
I think generic-cl has a slightly different target, though the = operator could be used for this use indeed.
14:10:23
phoe
madnificent: that's why I wanted you to read kmp's article - it provides an example implementation, some example categories, and a rationale for both :D
14:10:49
phoe
also, you can write implementations and tests for standard CL data structures to make your library immediatey useful
14:11:10
madnificent
phoe: I'm only searching for the defgeneric portion in some library. I'm trying to avoid reinventing the wheel.
14:11:23
madnificent
It seems the CL community receives a lot of dirt for it, and I don't think I'm an exception.
14:13:53
Shinmera
I've written and used a lot lot lot of libraries and systems. There was maybe one point where I wanted a generic equality test, and in that case it was trivial to just write it for the cases that actually mattered.
14:14:27
Shinmera
Imo a generic equality thing is something that seems like a no-brainer, but is actually almost entirely superfluous at best, and actively confusing at worst.
14:14:59
Shinmera
I don't even like equal/equalp, for instance, and instead wish hash-tables supported other tests like string= and string-equal.
14:15:19
moon-child
'epsilon' is always taken as absolute, when a relative epsilon may be wanted in some circumstances
14:17:13
madnificent
and I agree with you on that. Though a shared known vocabulary is handy. Like alexandria provides tools, this could provide generic methods. I see that some have attempted a base implementation too.
14:18:15
madnificent
thanks for all the pointers and lovely argumentation moon-child, phoe, mfiano, Shinmera
14:19:05
phoe
what if in one part of my code I want to be sure that two slots of FOO refer to objects that are just EQUAL, because I only care about their value
14:19:12
madnificent
(my gut-feeling says that deep research would land at something that involves something like ContextL)
14:19:23
phoe
and in another part of the code I want them to be EQ, because I case about their identity
14:19:57
phoe
and what if method for FOO is defined elsewhere and I cannot really redefine it or put an :around on it
14:20:06
madnificent
I'm searching for ways of making an informed decision, rather than assuming a single method can be implemented that works for all.
14:21:24
phoe
I'm just pointing out possible problems that have been discovered so far and that a Truly Generic Equality Operator® would need to take into account
14:22:42
madnificent
Yes. Perhaps it would be possible to define the strictnes of equality in a tree (but perhaps not!) and if that would be the case, then perhaps an extra argument could help in that regard. Perhaps objects could define their own "default" for equality and indicate they implement that. I don't know. I wonder though!
14:24:10
phoe
well, this already sounds like (setf (fdefinition 'foo-equal) (make-equality-predicate ...)) :D
14:25:02
_death
one issue is that the result of an extensible equality operator may change at different points in time.. (equals x y) => nil ... seasons pass and methods are added, (equals x y) => t ... often an equality operator is presumed to be a (mathematical) function, so this is undesirable
14:25:45
phoe
and that sounds like a lot of work for creating a framework/factory for different equality and equivalence predicates, whereas I'll do simply (defun my-equal (x y) (= (mod x 5) (mod y 5)))
14:26:43
moon-child
phoe: both of those are expressible as an existing equality function with some key
14:26:48
madnificent
phoe: you could roll your own loop too. But that's what apparently is attributed to lisp being hard. It's too easy to roll your own things and there's too little consensus. Then again, that's by people outside of the community so what do I know.
14:27:39
madnificent
but really, what is worse: seeing (my-lib:equal 5 7) -> true, or seeing (shared:equal 5 7 'odd-p) -> true
14:28:03
madnificent
I'd be seriously surprised on the first result, but if there'd be a shared infrastructure I'd be only weary to see the second.
14:28:39
madnificent
After this, the challenge becomes the definition of symbols like 'odd-p in the same namespace. Preferable ones the community sees value in.
14:28:57
Alfr
madnificent, if it's necessary to pass along something extra to specify how two thing are to be tested for equivalence, then you could also simply pass along such a predicate function.
14:29:28
madnificent
Alfr: true, but then I'm again at the situation where I don't have a place to discover what good options are for equality functions and what to think about.
14:30:05
madnificent
Alfr: My search was not for an implementation, but rather for defgeneric things so I can be more informed in my implementation, and so the community can have a shared vocabulary.
14:30:50
mfiano
Are we no longer talking about a generic function which would not be able to portably dispatch on the value of a keyword argument?
14:31:22
madnificent
mfiano: I think we're joking to vent frustration and avoid the point of the discussion. But not sure.
14:31:45
phoe
(defun equal (x y &key z) (%equal x y z)) (defgeneric %equal (x y z)) ; here's your dispatch
14:31:50
moon-child
I interpreted (equal 5 7 :key #'oddp :test #'eq) as completely serious, and it seems reasonable to me
14:31:53
madnificent
mfiano: my gut-feeling says the keyword argument itself likely belongs to some form of inheritance.
14:32:27
madnificent
moon-child: Ah! I was looking for terms that conveyed a meaning. This suggestion conveys an implementation instead. Comparing two forms of equality based on their intention is harder that way.
14:33:13
madnificent
moon-child: That example would work for numbers, but you can hardly port it to objects of some kind. It lacks a higher-level meaning. An intention.
14:33:14
Alfr
madnificent, call it an equivalence relation? (And make sure it is one, otherwise unexpected things will happen that one does not expect from =, eql etc.)
14:34:04
madnificent
Alfr: sounds reasonable. That's also what http://www.nhplace.com/kent/PS/EQUAL.html uses (but because equal was taken)
14:34:08
moon-child
what higher-level meaning or intention could you possibly assign to 'have the same evenness/oddness'?
14:34:22
Alfr
madnificent, I think your underlying problem is that on a set of things you can define many such relations.
14:34:46
Alfr
madnificent, in particular every partition of the set corresponds to one such relation.
14:34:49
madnificent
moon-child: perhaps it's not the best candidate for an equivalence function then. Why would you use that function? Meaning comes from the use, rather than the implementation. With only an implementation it's hard to indicate a meaning for me.
14:35:26
madnificent
Alfr: Yes. But some common things likely pop up. It's valuable to share a vocabulary on those.
14:36:06
madnificent
Like: I jotted down a prolog thing at some point because I couldn't download the prolog compiler/runtime and I had to make a school assignment. I could use that if I'd find it back, but I'd rather share a solution.
14:36:37
madnificent
not even because of bugs, but also because it's makes things easier to read for others. When you see split-sequence:split-sequence you probably already know it. Similar for Alexandria.
14:40:57
_death
you could create an equality function builder.. like (create-equality-function :atomic-test (disjoin (conjoin #'integerp #'oddp) #'eql) :descend-into '(vector list)) ;; or something
14:42:35
madnificent
I could. But that still leaves open the whole issue of having a good description on the intended equality, which is what I was searching a solution for.
14:44:31
madnificent
_death: somewhere in the beginning I pointed out that having a shared vocabulary is handy. it both helps you wire implementations together easily, as well as teach you good solutions (and shows pitfalls). like the statement Kent makes "you won't find one good equality, make sure you can have many"
14:46:21
_death
madnificent: in a create-equality-function case, a vocabulary is created.. terms for concepts like atomic or primitive test, descent into structures, etc.
14:48:27
_death
I'm also reminded of that quick hack https://gist.github.com/death/6a441602bd6acebda067dd900e56e256
14:50:06
madnificent
_death: I doubt it would teach me what a good equality operator is and what should be taken into account for creating one. It could help define equality once that information was shared.
14:50:10
_death
here the vocabulary consists of equality definition operators like funcall/and/call/nest/store
14:51:57
_death
madnificent: well, logicians already had that covered with the definition of equivalence relation
14:52:08
madnificent
_death: for the few things that make sense to me (store doesn't immediately), that looks like a cool way of implementing various ways to compare things.
14:54:53
madnificent
On the upside, this discussion has made my docstring substantially better already! Thanks :D
16:05:52
madnificent
Hello again from the questions agancy. IIUC, cl-ppcre should be able to understand unicode characters thrown at it. Does that require any specific setting? I'm not getting expected results with character ranges.
16:11:02
White_Flame
madnificent: best to use char-code to ensure that what you're testing with/against is what you expect numerically, since these are about ranges
16:12:05
White_Flame
if the string has combining forms, instead of single code points, that will muck with things as well
16:12:29
madnificent
White_Flame: I convert from the hex code to a character when constructing the regex string and a string with ; matches [#x10000-#xEFFFF] which doesn't seem right.
16:13:58
White_Flame
(because of stuff like this: https://www.greece10best.com/wp-content/uploads/2018/08/8-7-696x400.jpg )
16:14:39
madnificent
White_Flame: That should only match if I explicitly entered the other semicolon and not one in the supplied range.
16:18:15
madnificent
If you try to replace #x[0-9A-F]{1,4} and expect #x10000 to match completely, you're o_O
16:19:51
frodef
Hi all, I'm using DEX:REQUEST to download some HTTP. When there's network issues, it seems to just hang forever, despite DEX:*DEFAULT-READ-TIMEOUT* being set to e.g. 10. When I inspect the stack etc. at the point of hanging, there seems to be no timeout-mechanism that has trickled down to the lower abstraction layers. Does anyone happen to know about this?
16:26:06
madnificent
frodef: I don't know, but maybe maybe drakma does work? This isn't what you want to hear but the closest I get.
16:29:12
frodef
I seem to be able to provoke a "standard" read timeout, so I'm guessing it's a matter of the timeout mechanism not being consistently propagated to the lower I/O calls.
16:42:03
frodef
There's already a bug-report, dated september 2020, and zero response. That's not a good sign, I suppose. https://github.com/fukamachi/dexador/issues/91
16:46:25
mfiano
the lone wolf way of CL, cranking out code to satisfy personal requirements with no replies to issues
16:47:34
mfiano
I think it's been about 5 ot 6 years since my issues were posted and still waiting on replies
16:49:13
frodef
I suppose this does highlight a bit of the problem with the CL scene.. it's never quite clear what is the canonical thing (i.e. library).
16:50:21
frodef
phoe: yes, but it's a bit sad to include "what is the latest github checkin" in my search parameters for a HTTP library.
16:52:06
madnificent
frodef: The only thing I've effectively seen work in communities is individuals putting in the time to check libraries and evaluate them.
16:54:10
mfiano
Personally I use dexador, and make lots of hacks locally to fix things. Not a recommended way to go for fukamachiware for the sane.
16:55:42
Xach
for wigflip.com i wrote both an http client and a dns client so i had fine control over fetching resources over the nasty net
16:56:34
frodef
Maybe there should be some sort of semi-social mechanism overlaying quicklisp? Something to indicate confidence level in general, and particularly for a list of standard library functionality (e.g. http download)
16:57:16
White_Flame
there were popularity lists posted, saying which QL systems were downloaded the most, at least
16:57:39
frodef
phoe: no, something that essentially says "86% of people use <this> for downloading HTTP", etc.
16:57:45
White_Flame
Xach: but those do change over time, too, so static old reviews aren't great here
16:58:13
Xach
White_Flame: yes, and if you leave one star, a foreign programmer will offer you a $25 amazon gift card to remove it
17:05:02
frodef
I suspect the thing is, CL lacks the Benevolent Dictator that most others have (or at least had while building community).
17:14:45
semz
The BD comes with his own set of problems. Just look at van Rossum crippling functional programming in Python.
17:34:54
jeffrey
frodef, are you using HTTPS instead of HTTP by any chance? When I try `(time (nth-value 1 (dex:get "https://httpbin.org/delay/10" :read-timeout 2)))` without HTTPS I get the error
17:50:28
madnificent
frodef: I was joking. I meant that if there is no such feature in drakma, then it can also have no such bug. It was not helpful. Sorry.
18:34:18
phoe
does anyone know of a utility that produces a string-output-stream for a given string with indefinite extent?
18:34:36
phoe
something like (with-output-to-string (stream string) ...) except where STREAM is not DX
18:55:25
marcoxa
frodef: "deals with timeouts" is quite a statement given any CL implementation period. With or without SQL.
19:33:51
lisp123
edgar-rft: But Planet Lisp is only the human incarnation of secret alien technology ;)
19:37:23
frodef
seems to me that the state of "alien technology" is that I simply cannot reliably download some files over HTTPS. (sorry, I'm just slightly frustrated by this..)
19:42:47
frodef
rotateq: That's pretty much how I expect these things are usually solved in practice. Kill the process and start over. The ultimate Garbage Collection.
19:44:15
theothornhill
frodef: I'm sure I'm totally missing the point, but did you try trivial-download?
19:49:44
theothornhill
Not sure what your problem is, but I use that in a utility to download pdfs all the time
19:50:40
frodef
theothornhill: my problem is what happens when the network hangs, or rather when a timeout occurs.
19:53:52
aeth
when you have to interface with the rest of the world, you're going to have to deal with a messy situation, and potentially error codes
19:53:55
theothornhill
And connection-timeout isn't helping you? Sorry if this is just looping over things already mentioned
19:54:20
aeth
even 100% native CL isn't going to help you with networking because the network protocol isn't going to be written with CL objects in mind
19:56:06
frodef
theothornhill: I need read-timeout, not just connection-timeout. And the latter is just ignored for SSL with Dexador.
19:58:23
frodef
aeth: Sure, but dealing with "messy things" is kinda what I was hoping CL and its culture was supposed to deal with well.
19:59:13
aeth
frodef: the problems of CFFI (or asm OS access if the OS has a stable API, but only Linux does afaik... the rest want you to go through C), DBs, and networking are just inherently messy
20:00:19
aeth
I guess networking these days is mostly just "Do you have a JSON parser?", but they have subtle incompatibilities with each other and none of the CL JSON parsers are particularly good imo
20:01:16
frodef
aeth: I know that stuff is messy, and I can accept there are corner cases that can't be dealt with well. But this is just a plain download, dealing with a plain network outage.
20:02:08
marcoxa
frodef: I am saying (w.r.t. timeouts) that no semantics has been completely claified in any implementation. We had a long discussion on th epro mailing list some time ago.
20:02:39
aeth
in particular, there is no READ-BYTE-NO-HANG (just READ-CHAR-NO-HANG) so if you read bytes (which you should, since the encoding over the network is unlikely to be exactly what your CL implementation expects)... you can... you know... hang
20:02:47
marcoxa
and yes... the issus came out about the use of usocket. I don't remember the details.
20:03:11
aeth
You can guard the hanging with a check to LISTEN, but that does not give an error on the loss of the connection (it's defined not to, iirc)
20:04:24
aeth
So you either do a hanging read and get an error on connection loss (I guess a background thread makes that possible), or you do a non-hanging read (manually, by checking LISTEN first) and only READ-BYTE when LISTEN is T, but it doesn't tell you when there's a detected disconnection... So you can be waiting forever on a dead connection
20:05:07
theothornhill
frodef: *default-read-timeout* is a no-go, at least. It is only defined, not used anywhere as far as I can tell
20:05:19
aeth
yitzi: for starters, about 80% of them if not 100% of them don't understand the CL type system, preferring to treat NIL as null rather than as false
20:05:32
aeth
(by default, but everyone knows that defaults matter because virtually everyone uses the defaults)
20:06:22
aeth
since NIL could be null (terrible idea; just use :null or 'null) or could be false or could be the empty list
20:07:07
aeth
oh, and if you use plists/alists for JSON objects now you have an additional ambiguity
20:07:59
frodef
Given the state of "Enterprise Software", I've found that the performance of JSON parsers is actually important. They need to gobble up megabytes...
20:11:05
aeth
now you have the issue, though, of (1) getting it in Quicklisp and (2) getting everything that uses JSON to move over to one of the conforming and round-trip libraries
20:14:53
aeth
I would say that the two biggest issues historically have been (1) no serious JSON library, (2) poor support for encrypted networking (e.g. HTTPS)
20:20:53
lisp123
I'm suprised how often JSON comes up in Lisp circles, I never thought it would be that hard to parse
20:24:58
yitzi
That the spec is ambiguous and ill defined does not help. And in my opinion it is not hard to parse, just that most of the parsers are just slightly flawed...IMHO.