freenode/#lisp - IRC Chatlog
Search
21:57:07
no-defun-allowed
It could go wrong if you try something like (let ((x ...)) (loop for x = x then ...)) since LOOP will set up another binding for X.
23:02:44
jeosol
is anyone using CL to develop rest API applications. I am quite comfortable using some web libs (hunchentoot, caveman, etc) but not an expert. Wondering if anyone has some rest API examples to share or their applications.
0:33:32
dlowe
jeosol: I just (setf (hunchentoot:content-type*) "application/json") and then return (json-encode-json-to-string `((:status . "ok") ...))
0:35:01
dlowe
The session handling on hunchentoot is kinda primitive and prone to hacking, though. Thinking about writing my own.
0:36:27
jeosol
Someone told me about django-rest, but I don't want to be using two languages, if CL can get me what I want.
1:52:35
Josh_2
I have https://imgur.com/ELuz2SF.png and https://imgur.com/8sPkVqG.png but when I try to call the following https://imgur.com/xzuHV0f.png I just get undefined function call, I thought if you :use a package in your own defpackage it pulls the symbols from that package into your new one
1:58:40
Josh_2
what am I missing with all this packaging stuff that means I can't call the functions from my the packages I :use?
2:01:23
aeth
Josh_2: you don't export 'write-pin you export '|write-pin| because you're using the symbol named "write-pin" not "WRITE-PIN". Things are upcased by default, not case-insensitive by default.
2:02:25
aeth
You can export "WRITE-PIN" and some people use it as a micro-optimization. This might be important if you're running it on a computer from the 1980s.
2:41:54
mister_m
When defining a macro, and using a let statement with a (gensym) invocation, is there a way I can provide a value to the let-binding in addition to having the macro expander generate a symbol for me? Or do I need to invoke (gensym) in one let binding, and then assign to the gen'd symbol in other using let*?
2:52:54
Xach
mister_m: i don't fully follow the question, but macros are just functions return source code, so you can use anything you like to form that returned code
3:00:49
mister_m
Xach right, but in a let binding i can provide a value (let ((thing "test")) ...) - can i provide a value if I also have to (gensym) the ``thing`` binding?
3:09:18
Xach
references to that symbol in other parts of the code only care about its identity, not its name or package
3:12:36
pjb
(let ((s1 (intern "FOO" #|in this package|#))) (unintern s1) (let ((s2 (intern "FOO" #|in this package|#))) (list (eq s1 s2) (symbol-name s1) (symbol-name s2) ))) #| --> (nil "FOO" "FOO") |#
5:59:28
mfiano
Is POSITION the idiomatic thing to use when checking for the presence of an element in a vector, when the vector can have nil elements and the element to be checked can also be nil?
6:01:26
mfiano
Ok. I'll just add a comment because I can see that confusing me at a later date (not using the integral return; this is simple for an ASSERT).
6:03:11
beach
The reader expects a Boolean value for IF and ASSERT, but POSITION does not return a Boolean value.
6:03:25
mfiano
Can you elaborate on the "don't do (assert (position ...)), or is that the PN/KP thing too?
6:04:25
aeth
beach: so would the correct behavior be to define a function that does (if (position ...) t nil) then?
6:05:13
mfiano
Is there a distinction in the spec that specifies that it cannot be a generalized boolean? Maybe I should just read this paper. Have a link, beach?
6:05:55
beach
mfiano: It has nothing to do with semantics. It has to do with the message that you send to the person reading your code.
6:06:22
beach
If we were only interested in semantics, there would be no problem with obfuscated code.
6:08:14
mfiano
Aha, ok. I was reading the title. That is the venue if I actually click through to one of them :)
6:15:21
mfiano
beach: So would you do (unless (null (position nil sequence)) t), (not (null (position nil sequence))), or other for ASSERT?
6:19:05
beach
Or more likely, I would signal an error, as in (when (null (position ...)) (error...))
7:28:49
pjb
beach: you are wrong: IF and ASSERT DO NOT EXPECT a BOOLEAN! They expect a generalized boolean. POSITION returns a generalized boolean. It's perfectly compatible with IF or ASSERT.
7:29:46
pjb
Of course, you are entitled to write your programs in a subset of CL, and nobody will reproach it to you. But people can use the full CL language.
7:31:11
aeth
it's funny that the three of us have different opinions here because I'd still say write a trivial function (inline it if performance is a concern, since its so trivial its implementation will never change) that is self-documenting in its name
7:47:20
beach
pjb: You must have read only part of the exchange. I explicitly said that it has nothing to do with semantics, and everything to do with communication with the person reading the code.
7:49:17
pjb
Still my point. (if (not (null (position …))) …) is a heavier cognitive load, to somebody who knows CL. When I see it, I start to wonder what's happening so special, why don't we just test (if (position …) …). And it's not even a double negation such as (not (not …)). You have to think hard to realize that it meant nothing.
7:50:01
pjb
beach: I realize that one can expect from smart and even not so smart compilers to optimize (not (null …)) out.
7:53:59
beach
I find it amusing that my arguments about conventions are nearly always met with individual opinions. Let me give a parallel concerning English prose.
7:54:06
beach
*I* might think it is fine to write text that has dangling participles, because after all *I* wrote it so *I* know what I meant. But that's not the point.
7:54:22
beach
The point is that even though *I* don't mind writing and reading such prose, I still don't write like that when it is meant for other people to read.
7:54:30
beach
When I write for other people to read, I can't ask each individual reader what they want, because I probably don't even know them. So I have to follow CONVENTIONS, whether I like those conventions or not.
7:54:32
beach
This aspect seems to be lost on many people here, very likely because they have little or no experience with working in teams, or with writing code that might some day be maintained by others.
7:55:11
pjb
beach: you are assuming what other people expect. I'm telling you that for me, it's harder to read (if (not (null (position …))) …) than (if (position …) …).
7:56:27
beach
I am not assuming what other people expect. I am posing that we should all adopt the same conventions, thereby getting used to what others expect. Of course, the way the community is made up right not, this is impossible.
7:58:06
pjb
When you call a function, you have to know what type of argument it expects, and what type of results it returns. If you write in a subset of the language that don't assume all the possible values, you are both limiting yourself and risking serious problems.
7:58:49
pjb
We see the problems all the time in C, because a lot of people don't know C, but assume some higher level language with C syntax…
7:58:50
MichaelRaskin
If you use English as analogy, let's consider the amazing convention of never splitting an infinitive and how it used to phrases that look tortured (and are still no easier to read)
7:59:02
fengshaun
is it possible to have the local copy of hyperspec be searchable (short of grep'ing the directory)?
7:59:39
pjb
fengshaun: there's a version of it in info format (it was distributed once with gcl IIRC).
7:59:47
beach
MichaelRaskin: That is not a convention. It is a stupid idea proposed by besservissers who have no training. Check Pinker for a more informed opinion.
8:00:38
beach
MichaelRaskin: I am quoting Norvig and Pitman for a reason. I consider them the analogue of Pinker.
8:01:07
MichaelRaskin
beach: it _is_ literally a convention. A Convention produced by people who didn't understand what they are doing, but now (unfortunately) widespread enough to become a convention in many places.
8:01:45
MichaelRaskin
I know that a lot of conventions proposed make code harder to read for me whenever they are literally followed
8:02:59
beach
MichaelRaskin: They only make it harder to read for people who stubbornly refuse to follow conventions established by smart, experienced, and knowledgeable people like Norvig and Pitman.
8:03:29
aeth
I personally follow a version of WP:IAR (ignore all [the] rules) in my projects. https://en.wikipedia.org/wiki/WP:IAR
8:03:45
aeth
e.g. my line length limit is 100 lines, but I go over that in a few places, because sometimes it makes things less readable to put a fake break in
8:04:20
beach
I think I totally fail to get this idea across, and I shouldn't be surprised. I will stop trying now.
8:04:29
MichaelRaskin
beach: when people who actually follow the specific authority are not easier to find than people who think this authority is harmful...
8:04:51
pjb
beach: and there is old code that you still have to be able to read. This is why I think my approach is better: stick to the CLHS.
8:05:12
beach
pjb: Yeah, and the other day we saw someone saying that "Norvig is a traitor", so we shouldn't listen to him either. Sheesh!