freenode/#lisp - IRC Chatlog
Search
8:36:50
matzy_
so if i define an *acceptor* (I believe it is a class) and pass it to (hunchentoot:start *acceptor*) (literally that's my code), I get an error
8:45:00
matzy_
literally copying and pasting the third and fourth codeblocks on this page to see how serving files works: https://lispcookbook.github.io/cl-cookbook/web.html
8:47:12
matzy_
whereas the one-liner (hunchentoot:start (make-instance 'hunchentoot:easy-acceptor :port 4242)) run without any errors
8:49:49
matzy_
so the first example doesn't work either. I should clarify. Directly under the "Simple Webserver" huge heading, there's another "Serve Local Files" big header, and then under that is a "Hunchentoot" header, and it's the subsequent codeblocks that i'm literally pasting in emacs and they're not working
8:50:17
Shinmera
The code is obviously correct so whatever you're actually doing that isn't code must be wrong.
9:40:49
Shinmera
It won't be as fast as crypto algorithms that were hand tuned by tons of people, but it's good enough (at least on SBCL)
9:46:22
MichaelRaskin
Note that assembly implementations of cryptographic algorithms are usually also tuned against timing leaks.
9:51:11
jackdaniel
if I ever start a collective I'll call it dulllispers, three "l" there look like a great typo
10:49:54
jackdaniel
are these lambda lists [gf] (A &REST ARGS &KEY FOO &ALLOW-OTHER-KEYS) and [method] (A &KEY PAYLOAD) congruent?
10:49:58
specbot
Congruent Lambda-lists for all Methods of a Generic Function: http://www.lispworks.com/reference/HyperSpec/Body/07_fd.htm
10:50:24
jackdaniel
reading 4th point carefully seems to say: "no", because "each method must accept all of the keyword names mentioned after &key, either by accepting them explicitly, by specifying &allow-other-keys, or by specifying &rest but not &key."
10:53:09
specbot
Keyword Arguments in Generic Functions and Methods: http://www.lispworks.com/reference/HyperSpec/Body/07_fe.htm
10:56:47
Shinmera
jackdaniel: But point 5 says &allow-other-keys may be omitted as long as it is on at least one method or the gf.
11:02:08
jackdaniel
Shinmera: point 5. says "any keyword arguments may be mentioned in the call to the generic function. ", not "then method doesn't have to accept all of the keyword names mentioned after &key"
11:04:00
Shinmera
7.6.5 also says: If the lambda list of any applicable method or of the generic function definition contains &allow-other-keys, all keyword arguments are accepted by the generic function.
11:05:05
Shinmera
Well, I'll give you the practical answer of: if you made it illegal to omit keyword arguments you would break a lot of code out there :)
11:06:22
jackdaniel
https://gitlab.com/embeddable-common-lisp/ecl/uploads/b754370025423cb0d90595d8d67e1d93/ecl-pivot-ccmp.html
11:13:57
jackdaniel
thanks, I'm still wondering if the interpretation should be loosened on ECL. I'll see what other implementations do
11:34:06
kpoeck
There seem to be cases where repositories are both on github and https://gitlab.common-lisp.net/ and the content is not the same
11:35:34
kpoeck
In you case https://gitlab.common-lisp.net/mcclim and https://github.com/McCLIM/McCLIM
11:36:58
kpoeck
The latest commit on https://gitlab.common-lisp.net/mcclim/mcclim/-/commits/master is like 7 years ago, so this is probably abandonned
11:39:19
kpoeck
I am asking since I just made a pr to zacl on https://gitlab.common-lisp.net/zbeane/zacl and there is also https://github.com/xach/zacl
11:40:20
kpoeck
in this case the github version seems to be abandonned and is missing 1 year of changes
12:18:03
Xach
kpoeck: zacl was paid work and the payor demanded i use common-lisp.net. after the payment was done i switched to github, because that's what i prefer.
12:22:09
kpoeck
A technical question, in zacl - or better in zaserve - I have the problem that the "MP" package is used both in zacl and in clasp
12:23:56
Xach
kpoeck: it looks as though the clnet one is the most up-to-date and i can accomodate PRs there
12:26:35
eta
Shinmera, okay, is there a way to check whether a string would *encode* to valid UTF-8? ;P
12:28:20
Shinmera
unicode attempts to cover every character set out there, meaning the chance you get a string with a character set not covered by unicode is extremely slim.
12:28:23
eta
basically I'm debugging a crash where a "Illegal :UTF-8 character starting at position 0." error got thrown
12:28:53
loke`
Shinmera: actually it depends on Lisp implementation. Unicode only support 21 bits (well, a bit over 20 bits to be precise).
12:29:13
loke`
If you have an implementation that allows characters above that, then you have invalidUnicode.
12:29:48
eta
and I think some idiot might have managed to set their whatsapp status to a non-UTF-8 string
12:29:48
loke`
But, in SBCL as far as I can remember, a character is defined to be a valid Unicode codepoint, in that implementation there is no such thing as an invalid string.
12:31:01
loke`
eta: You can use the INCOV package (on quicklisp). It has the most robust error recovery parsing.
12:31:08
Bike
http://www.sbcl.org/manual/#Supported-External-Formats here's a list of the encodings supported by sbcl, if it helps.
12:31:26
loke`
eta: It provides restarts that allows you to look at the invalid text and then invoke the restart with the specified replacement character.
12:32:59
Shinmera
eta: it's likely that there's some byte padding or some other structure that you're not skipping.
12:37:13
eta
well check out {\\\"status\\\":\\\"\\\\ud83c\\\\uddf5\\\\ud83c\\\\uddf9\\\\ud83c\\\\uddec\\\\ud83c\\\\udde7\\\"}
12:39:54
Bike
what shinmera is trying to say is that you seem to be persistently confusing strings and their encodings as byte sequences. That string is perfectly encodable as UTF-8; but you're not dealing with a string, you're dealing with a byte sequence you got from the wire or something.
12:40:43
jcowan
When you represent characters in JSON strings as backslashed \uxxxx, you havd to use UTF-16 conventions. But the encodijng of a JSON value should always be UTF-8.
12:43:41
jcowan
At that level, yes. But then JSON string values can generate errors if they contain invalid escape sequences. Those are encoding/decoding errors at a different level
12:43:47
Bike
The error you showed looks like you're trying to decode a stream of bytes into a string, but the byte sequence is not actually UTF-8.
12:47:36
edgar-rft
let's introduce NOT-ENCODING-ERROR conditions for errors that happen while not encoding
12:48:42
mood
That does not apply to the string posted though, that (with some \\ removed) appears to be a Portuguese flag followed by a British flag
12:55:18
eta
so it looks like I need to scan through the JSON strings for characters that are invalid in UTF-8
12:55:32
Bike
So the problem here is that the codepoint DEAD is a surrogate and not actually a character?
12:58:12
Bike
utf-8 is simple enough that you could come up with a byte sequence for the DEAD codepoint fine
12:59:13
Bike
so i suppose more pedantically we would say that UTF-8 is an encoding of code points to bytes, not characters to bytes
12:59:29
eta
> Since RFC 3629 (November 2003), the high and low surrogate halves used by UTF-16 (U+D800 through U+DFFF) and code points not encodable by UTF-16 (those after U+10FFFF) are not legal Unicode values, and their UTF-8 encoding must be treated as an invalid byte sequence.
13:00:32
Bike
actually i'm not sure about the particulars of what this means. you can encode it but not decode it, maybe?
13:00:59
splittist
What about all the lisp strings between 1958 and November 2003? (Bring back EXPLODE)
13:01:09
eta
(substitute-if #\uFFFD (lambda (ch) (and (>= (char-code ch) #xD800) (<= (char-code ch) #xDFFF))) str))
13:07:11
eta
it should be reading the UTF-16 surrogate pairs and pairing them up instead of just blindly calling CODE-CHAR
13:11:35
beach
eta: While we are at it, errors are not "thrown" in Common Lisp. They are signaled. It is important because THROW means something entirely different in Common Lisp.
13:12:17
eta
beach, sorry! I do know that, just don't take much care and abuse the term 'throw' >_< I'll try and be more careful though!
13:14:21
Bike
oh, i see, cl:code-char is defined to return NIL if the code doesn't correspond to a character
13:18:17
jcowan
Why is that bad? Think of code-char as searching a notional association list between codes and chars.
13:19:08
kpoeck
in sbcl (list (code-char #xD83C) (code-char #xDDF5) (code-char #xD83C) (code-char #xDDF99) (code-char #xD83C) (code-char #xDDEC) (code-char #xD83C) (code-char #xDDE7)) -> (#\UD83C #\UDDF5 #\UD83C #\UDDF99 #\UD83C #\UDDEC #\UD83C #\UDDE7)
13:19:45
Bike
jcowan: because i'd prefer a "code X does not correspond to a character" to a "NIL is not of type CHARACTER"
13:21:33
_death
Bike: it's worse than that, if NIL is interpreted as something else.. this is another pitfall (maybe it should've been called code-char-p)
13:22:10
jcowan
There really are a whole lot of conventions for representing the behavior of partial functions: value vs. NIL, value vs. no values, two values (some value and validity flag), a Maybe class object
13:27:04
eta
sounds like I want https://github.com/anarchodin/trivial-utf-16, which isn't in quicklisp :(
13:31:09
Shinmera
eta: like what? You can stuff your integers into a byte vector and hand them to babel to do the decoding.
15:06:38
jmercouris
is there a syntax for declaring a struct? e.g. not using (make-xyz ...) where xyz is the name of the struct?
15:14:21
_death
it only has to exist when the form is evaluated.. it may be declared inline later on so you get a warning
15:17:05
_death
it means the compiler may signal a warning if it already compiled references to a function that's now declaimed inline
15:21:03
jmercouris
I set it as the initform, and it is not executed until the object is instantiated
15:21:14
jmercouris
so, does the compiler not go through and say "hey, this function does not exist!"?
15:23:29
jmercouris
I have a defclass with some slots, one of them has an initform with the value (list (make-xyz ...))
15:24:00
_death
in Lisp, you can reference names to functions that are not yet defined.. as long as you don't try to evaluate the form, no error should occur
15:27:20
beach
You might get a warning though, depending on the implementation. But if your function is defined in the image that you are compiling from, the compiler will take that definition as proof that the function does exist.
15:29:17
beach
jmercouris: In your case, you will get a style warning from SBCL if you compile a file with your DEFCLASS form in it from a fresh Common Lisp image.
15:29:41
_death
there's also a notinline declaration.. it will force the compiler not to inline and likely not to give inline warnings ;)
16:00:18
abbe
could anyone please tell me what's wrong with this code: https://pastebin.com/HRbuBxsB ?
16:02:57
abbe
also is there some built-in function to find the last element in a sequence, or (aref name (- (length name) 1) ) is the best ?
16:03:42
Bike
(i.e., a sequence that can be either a vector or a list or some implementation-defined gizmo.)
16:03:54
jackdaniel
abbe: if you can afford using alexandria (which is a very popular utility library), you may use (alexandria:last-elt sequence)
17:14:17
jcowan
beach: what is so great about 1-? It saves one space character and should produce exactly the same result when compiled, I would hope.
17:18:03
jackdaniel
IMO it is easier for human brain (common lisp programmer will scan 1- like other known operators, while for (- …) it will need to parse also the argument in question
17:26:14
specbot
Potential Numbers as Tokens: http://www.lispworks.com/reference/HyperSpec/Body/02_caa.htm
17:28:58
jcowan
Huh, and here I thought eclector would be quite clear about potential numbers, at least in strict mode.
17:29:48
Bike
i'm not sure i quite understand how this works. does an implementation have to signal an error here or is treating it as a symbol okay?
17:30:42
_death
I see, but that a conforming implementation may treat it differently does not prohibits its use
17:34:09
jcowan
However, an implementation that defines some kind of potential number needs to be told about it, not just to have it stuffed under the rug as just another symbol.
17:34:50
jackdaniel
it is nice when unspecified behavior is signalled with all (if feasible) sensible behaviors proposed in form of restarts
17:38:26
jcowan
a:::b is technically not a reserved token, but the consequences are likewise unspecified
17:38:42
beach
jcowan: It's a very general rule in programming, namely, use the most specific construct that will accomplish the task. By doing it this way, you allow for the person reading your code to understand the intention much earlier. Of course (1- x) and (- x 1) is not much different, but if x spans several lines, it is.
17:39:35
jcowan
Fair point in general, although any editor with the brains to do paren matching will make that easy
17:40:48
jcowan
Also, compactness brings obscurity: cdaddr is probably best expanded to (cdr (car (cddr ...
17:44:43
jcowan
IIUC then it is an argument against sequence fns when you don't actually need the polymorphism of the arguments?
17:48:54
beach
But yes, the sequence functions are best used when the exact representation of the sequence is not known.
17:52:10
jackdaniel
in practice most (if not all) loop macros in today cl implementations *are* extensible, but these mechanisms are not documented nor compatible, so they are not usually used
17:56:01
Bike
clasp's loop happens to have enough in common with sbcl's that i could cargo-cult the code over no problem, which is good, because i absolutely do not understand the loop code
17:56:52
jcowan
SRFI 42, which is not a Scheme standard, provides iteration over lists, simple vectors, strings, integer ranges, real ranges, character ranges, and streams, and adding your own is easy. There is also a polymorphic iterator that looks at the type it is interating over, and that's extensible too.
17:57:36
Bike
i wrote a path for iterate (which i don't usually use) to see if i could, and it turned out i could but only inefficiently since iterate doesn't allow outer multiple-value-bind bindings for reasons i'm not clear on
17:58:39
jcowan
multiple values are always a bugbear in Lisp, because people forget to allow for them.
18:00:10
_death
jcowan: cl-su-ai has an example of a (perhaps imaginary?) "potential number" abuse.. Guy Steele defines a data type called a "mote"
18:00:13
Bike
yeah i'm just thinking of the "actually undelimited continuations are bad" articles i've read
18:00:57
Bike
https://common-lisp.net/project/iterate/doc/Destructuring.html#Destructuring here it was. "There are subtle interactions between variable declarations and evaluation order that make the correct implementation of multiple-value destructuring in a with somewhat tricky. "
18:02:08
jcowan
Unrelated question: does anyone have use cases for m-v-call with more than one producer function? It's come up for me once or twice years ago, but I can't remember quite why any motr
18:03:53
_death
jcowan: I had one.. at the time I defined (defmacro values-concat (&body forms) `(multiple-value-call #'values ,@forms)) for it
18:06:49
_death
jcowan: the form using it is (values-concat bloom (encode-bits-internal bloom)) .. encode-bits returns two values
18:07:24
Bike
only in the case of curry that can't be compiler macroed away, though. check functions.lisp
18:09:23
jcowan
I don't think a cons-free implementation of mv-call is possible; it has to be primitive
18:09:46
jcowan
Has anyone looked into a minimal basis set for special forms? Clearly the standard set is not minimal
18:10:54
Bike
people ask occasionally, but i don't know if the question is that interesting. there's that one paper on implementing them in terms of each other...
18:12:09
Bike
http://home.pipeline.com/~hbaker1/MetaCircular.html that paper, if you haven't seen it
18:17:05
Bike
i like the last one in there about macrotizing FUNCTION. a bit more support and maybe you wouldn't need any special operators at all, just macroexpand (lambda lambda-list . body) into `(make-closure ',analyzed-lambda-list ',analyzed-body)
18:17:58
jcowan
the first one seems bogus, emulating if with get, because get cannot be implemented without if.
18:19:30
Bike
i think that's the trick, really. there's lots of stuff in the language you can't do with just the special operators anyway. the special operators aren't a minimal operator set, they're just operators that the compiler is allowed to treat more mysteriously than it can functions or macros
18:20:34
_death
I guess it uses GET to give clue.. if boolean was 0 or 1, AREF would do, but it's NIL and non-NIL
18:23:08
Bike
oh, true that it's bogus in that it won't work if the condition evaluates to non-nil but non-T, though
18:24:31
jcowan
The Scheme standard basis set at runtime is variable reference, implicit function call, literals (including quote), if, setq, lambda. This is thought to be minimal, but I know of no proof. Outside runtime are macrolet, defpackage, and include (as in C).
18:26:20
Bike
well, if that's on the table, (defvar *aux* (vector nil (lambda (x y) (funcall x)) nil (lambda (x y) (funcall y))) (defmacro if (condition then &optional (else ''nil)) `(funcall (svref *aux* (length (string (not (not ,condition))))) ...))
18:29:25
Bike
http://okmij.org/ftp/Scheme/quote-as-macro.txt here's the quote as macro i was thinking about
18:35:13
Bike
i mean, (eval #(...)) returns immediately, right? so you could just macroexpand (quote #(...)) to #(...)
18:40:11
_death
in that same comment about the mote datatype, Steele remarks: "For example, I might extend my Common Lisp to evaluate a vector by evaluating its elements in parallel and returning the value of just one of them (implemented by choosing the value of whichever one finishes first)."
18:40:45
jcowan
he was much concerned with parallelism in those days: see the xapping example imn cltl
18:41:20
Bike
or fortress, but i guess that continues the "this might be a dumb way to denote a perfectly fine concept" concern
18:45:56
pjb
jcowan: () is a symbol, which is declared as a constant variable, whose value is CL:NIL when evaluating CL:NIL it's a symbol, which is declared as ac onstant variable, whose value is CL:NIL. Therefore the result is CL:NIL!
18:47:42
_death
the message is https://cl-su-ai.cddddr.org/msg02850.html btw.. more about portable code walkers
18:49:15
jcowan
When I wrote a Lisp interpreter long ago, the undefined-function-name logic checked to see if the name matched /c[ad]*r/ and emulated it on the spot
18:49:17
jmercouris
it doesn't mean I don't end up drawing little diagrams to figure out what it is doing
18:49:45
Bike
in modern CL objects other than symbols and conses are self evaluating, so the kind of extension steele talks about there is not possible
18:50:35
Bike
"A form that is neither a symbol nor a cons is defined to be a self-evaluating object. Evaluating such an object yields the same object as a result. "
18:51:02
_death
Bike: but the potential number thing is still possible.. hardcoding IPs and magic numbers in code looks fun
18:51:41
Bike
as far as i know, printability has no impact on evaluability at all, which seems sensible to me
18:51:43
jmercouris
are you telling me that the definition of self-evaluation means only returning the identity?
18:52:17
jmercouris
i just assumed self-evaluation meant that the object itself is a function which returns something
18:52:44
Bike
Sure, it's possible to imagine a world in which eval is a generic function and you can put methods on it, for example.
18:54:15
jmercouris
the only idea that made me consider it is the idea that behind self-evaluation, must be evaluation
18:54:49
alandipert
i understand lazy evaluation in other languages as something like Bike's idea of eval as generic,and conditional operators are specializations
18:55:05
Bike
well, i mean. eval is just a function. if eval had no behavior specified it wouldn't be a very easy to use function.
18:55:33
jcowan
Bike: your quote says "A form" not "An object", so I think evaluating an object that is not a form is undefined behavior
18:55:35
alandipert
i think maybe our understanding is similar, to the extent that a function is a kind fo stored sexp
18:57:31
jcowan
alas the definition of "evaluate" and "form" in the glossary are mutually recursive, but it definitely does not say that all objects are forms.
18:58:25
Bike
by the way, the generic eval thing i heard of here: https://www.piumarta.com/software/maru/ never heard of it elsewhere
18:59:39
Bike
the issue where they changed the non-cons-symbol evaluation behavior mentions having to quote vectors
19:00:18
jcowan
But you'd be surprised how common circularity is in even professionally produced language dictionaries.
19:00:59
Bike
i don't think i would be. CL is the language where prog2 returns the first value, after all
19:02:34
jcowan
jmercouris: No, a form is a symbol, compound form (non-empty list), or self-evaluating object (any object but a symbol or cons), so all forms are objects and vice versa
19:03:47
_death
jmercouris: personally I don't mind calling (1 2 3) a form, unless the context requires the distinction
19:04:55
jcowan
It isn't a form in the first sense ("object meant to be evaluated") because it obviously isn't, but it is a form in the second sense.
19:06:37
jcowan
General dictionaries (not like the CL glossary) are constantly hovering between circularity and "word not in" (a word is used in a definition but not defined). The two are incompatible in principle, but you want to minimize a weighted sum of the two
19:07:43
jmercouris
i wonder if you could make a dictionary starting from a single definition from which all are built
19:08:56
Bike
take fifty thousand pages to show that in at least some cases, a circle has an inside and an outside
19:10:05
Bike
http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.374.4778&rep=rep1&type=pdf little old now, but
19:52:15
phoe
21:02 < jcowan> jmercouris: No, a form is a symbol, compound form (non-empty list), or self-evaluating object (any object but a symbol or cons), so all forms are objects and vice versa
19:53:09
phoe
no, a compound form must be: "a non-empty list which is a form: a special form, a lambda form, a macro form, or a function form."