freenode/#lisp - IRC Chatlog
Search
5:01:12
PuercoPop
Yeah, this works on my machine: (net.html.generator:html ((:meta :charset "utf-8") (:body (:p "hello world"))))
5:19:56
random-jellyfish
(defvar *board* '( (2 'black) 'empty 'empty 'empty 'empty (5 'white) 'empty (3 'white) 'empty 'empty 'empty (5 'black) (5 'white) 'empty 'empty 'empty (3'black) 'empty (5 'black) 'empty 'empty 'empty 'empty (2 'white) )) (defun nth-slot (idx color) (if (eq color 'black) (nth idx *board*) (nth (- 23 idx) *board*))) (defun slot-pieces (idx color) (let ((slot (nth-slot idx color))) (if (eq slot 'empty) 0 (first slot))))
5:23:02
beach
random-jellyfish: This channel is dedicated to Common Lisp so it had better be Common Lisp.
5:29:49
beach
You need to study the rules of evaluation, and the definition of the special operator QUOTE.
5:30:48
beach
Since they are already inside a QUOTE special form, as indicated by the outermost quote, they are not in a position to be evaluated.
5:30:53
beach
You need to study the rules of evaluation, and the definition of the special operator QUOTE.
5:33:02
beach
Besides, symbols are considered names of functions only (with a few exceptions) when they are the first element of a compound expression. which is not the case here.
5:34:20
pjb
The only thing that quoting does is to read a list with two elements, the first one being CL:QUOTE.
5:35:05
pjb
(defvar *board* '((2 'black) 'empty) is read as (defvar *board* (CL:QUOTE ((2 (CL:QUOTE black)) (CL:QUOTE empty))))
5:35:31
pjb
so you see that if you evaluate this form, the variable *board* will be bound, if previously unbound, to the list ((2 (CL:QUOTE black)) (CL:QUOTE empty))
5:35:48
pjb
The second element of the first element of this list is a list of two elements: (CL:QUOTE black)
5:39:58
random-jellyfish
I understand quote changes the mode of evaluation, it switches from form mode to data mode
5:43:18
beach
random-jellyfish: As pjb said, when the READ function sees a ' character, it reads the expression that follows it, let say that expression is <expr>, then it returns (QUOTE <expr>).
5:44:58
beach
random-jellyfish: As you see, DEFVAR does not change the value of the variable if it already has one.
5:45:18
random-jellyfish
defparameter with a single quote before the first opening parenthesis? or no quotes at all?
5:47:26
beach
I suggest you get some rest then, then study the rules of evaluation in Common Lisp and then apply the new knowledge to your problem.
5:52:27
random-jellyfish
I noticed I understand better from analogies with other programming languages
6:18:12
jansc
Hi! Is there a CL library for converting a relative URL to an absolute URL, given a base URL? I'm looking for something like urljoin in python: urljoin('http://mysite.com/foo/bar/x.html', '../../images/img.png') => 'http://mysite.com/images/img.png'. Seems like purl and quri don't support this.
6:28:02
jansc
(merge-uris (parse-uri "../../images/img.png") (parse-uri "http://mysite.com/foo/bar/x.html"))
6:33:52
random-jellyfish
beach: thanks for that link earlier on form evaluation, sheds more light over my ignorance
12:44:46
LdBeth
Installed smartparens and I recall the reason last time I deleted that is I hate auto closing up parentheses which causes 1. hard to see how many parentheses I have to skip 2. REPL behavior annoying
12:46:15
beach
What if [ were to insert a [ as usual, and then when you type the ], the [ turns into ( and the ] turns into as many ) as required to close to [?
12:47:09
beach
Then the brackets would just be editor commands, and not present in the resulting code.
12:48:40
LdBeth
beach: yes, that is exactly what I think, and can be implemented with emacs’ marker feature
13:06:08
moldybits
with smartparen ) at a closing paren will skip over it and highlight the opening paren so i know where i am.
13:22:29
LdBeth
assume my cursor is |, now I have to skip unspecified number of ) to start a new sexp
13:28:56
LdBeth
Since I still have to take the same care which one match which, and types almost the same amount of )s
14:51:32
LdBeth
paule32: u add ":reader what-ever-name" after ":initarg :name" and call "(what-ever-name powerFuraCell-AAA)" to access the name slot
15:40:11
szmer
is there a way to get in SLIME/SBCL the version of a definition with purposes of variables like #:G8 visible? I already have optimize debug 3 declaimed, macroexpands don't do this
16:14:34
beach
szmer: I don't know the internals of SBCL, but that's the kind of thing that a typical compiler would generate for intermediate results that are not explicit in the source code.
16:16:13
beach
szmer: ... like if you have (f (g x)), the compiler may generate code such as (setq #:G234 (g x)) (setq #:G345 (f #:G234))
16:25:44
szmer
beach: but this http://www.sbcl.org/manual/#The-Processing-Path suggests that some representation like this should exists somewhere
16:38:00
another-user
where can i find list of all functions operating on trees like subst? iirc clhs had something like this but can't find it now
16:40:16
jcowan
FWIW, I don't avoid the use of `list` as a local variable in Scheme, as there is absolutely no need to do so unless I am going to call the standard `list` procedure within the lexical scope of the variable. That said, outside list libraries, it's usually better to call something foo-list to indicate that it has foos in it.
16:40:50
jcowan
This supposed advantage of Lisp-2s is really not much of an advantage. (There are others.)
16:42:00
edgar-rft
another-user: you probably are looking for Chapter 14.2 The Conses Dictionary, e.g. here http://www.lispworks.com/documentation/lw50/CLHS/Body/c_conses.htm
16:43:04
aeth
jcowan: I think you might underestimate how often this shows up in CL because you're used to Scheme. Separate class/type namespace is arguably as important as the other two, e.g. (check-type list list)
16:44:32
aeth
jcowan: And (check-type list list) is a bad example because a list often isn't a good name for a list. But foo is often a good name for a foo.
16:45:18
jcowan
Since types are not standardized, there are various approaches to naming them. As I noted on #scheme, I write <foo> for a record-type, reserving foo for the constructor of immutable records and make-foo for the constructor of mutable ones.
16:51:33
aeth
(In anticipation of being pinged 5 hours from now, yes, you can technically have a class named |Foo| in CL. No, you shouldn't do that and I think anyone who reviews pull requests on Github/Gitlab/etc. would fail such code.)
16:52:10
aeth
(Unless it's some really niche case that's interacting with foreign code or a database or something.)