freenode/#lisp - IRC Chatlog
Search
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."
20:13:53
_death
Load Symbol Character.. although it should really be LDC - LoaD Character and take string designators
21:30:55
samlamamma
Everyone knows that (+ "hello " "world") equals (+ "world" "hello "), I see no issue with this
21:42:48
samlamamma
Today I did not write a single line of code, but at least I discovered /r/lispmemes.
21:47:01
_death
if + is not necessarily associative, why be strict about commutativity? (= (+ (+ 0.1d0 0.2d0) 0.3d0) (+ 0.1d0 (+ 0.2d0 0.3d0))) ;)
22:06:43
jcowan
That's the way IEEE floats work: 2-argument + is commutative, but 3-arg + is not associative
22:12:07
jcowan
so we have established that (1 2 3) is not a form, and that (eval (1 2 3)) is undefined behavior, yes?
22:32:52
Bike
i think there was a way to get the bot to look up glossary entries, but i don't remember it
22:32:55
specbot
To use the specbot bot, say something like "database term", where database can be: clhs lp mop.
22:33:30
jcowan
no datum entry; object entry defines it as "datum", and also gives a contextual definition of "a foo object"
22:40:20
jcowan
datum in NL means date in EN, and very unfortunately indeed Daten in DE means both dates and data (as pl. of datum)
22:51:09
jcowan
a friend of mine from Texas but been working IT in Germany for decades tells his crew to say Datumswerte instead
23:00:21
jcowan
_death: Google Translate says Boolescher Wert, which I assume is pronounced "buhlscher"
23:02:56
Bike
this paper uses algol notation, which i don't understand, in order to explain the Plankalkül notation i also don't understand. pretty nice
23:07:48
jcowan
so a perfect hybrid of English root pronounced Englishly and German affix pronounced Germanwise
23:10:54
aeth
Is there a CLobol Cobol-in-CL and if not, why did they miss the opportunity to use that name?
23:27:55
aeth
If we're going to go down that route we might as well shut everything down except for ##javascript
23:52:29
jcowan
I don't see any CL-to-JS that's even close to complete in "language features" as opposed to "library features"
23:55:01
aeth
You can't really have something that's both efficient and a conforming CL in JS because the languages are just too different.
23:58:42
jasom
the biggest one being that you can't just dynamically generate assembly and then call it (which most traditional lisps do)
23:58:49
Bike
i think t hey still haven't implemented exceptions and it looks like they've decided to go with C++ style ones, which I can tell you from experience are an enormous pain in the ass to reconcile with lisp nonlocal control flow.
0:17:49
no-defun-allowed
All I know of is cl-javascript, which might be a bit dead, and doesn't run as fast as the JITting implementations.