freenode/#lisp - IRC Chatlog
Search
19:33:12
mister_m
I am trying ot use uiop:split-string to split a couple lines I am reading from a file by newline to create a list I can process. I am invoking (uiop:split-string lines :separator '(#\Newline)), but i get a single element list with the same string as the lines value I am passing to split-string. Am I missing something here? Does #\Newline not mean what I think it does?
19:38:28
mister_m
that's clever I'll remember that - looks like there is indeed a #\Newline in there
19:41:42
mister_m
_death: well, technically I am using a regex to extract a block of a file and working with those lines directly
20:07:39
Josh_2
can an integer be coerced into an array of It's bits? I want to access each bit in an integer individually
20:19:04
jcowan
I need help translating a non-CL LOOP construct into idiomatic CL LOOP. Of course I could use lower-level code instead, but I think it would be better to use LOOP here. Anybody feel like looking at this?
20:25:09
lukego
Hey is it possible to do SBCL20 as a "one dayer"? Like, arrive early morning, leave late night, do some meaningful talking with people in between? If so which date would work?
22:12:35
anlsh
Can anyone help me debug geiser-mode a bit :| None of my evaluation/send to repl functions seem to work
22:15:09
anlsh
Yup, so after running geiser-set-scheme I can run geiser-mode-switch-to-repl from the buffer and one will pop up
22:15:43
jackdaniel
anlsh: this channel is dedicated to common lisp (please see topic) so no many people will be able to help you here
22:17:21
LdBeth
anlsh: geiser has weird setting that requires your file extension matches the scheme implementation you use
22:23:49
anlsh
Hmm well I'm using chicken scheme and my source file is a .scm, which seems to be in line with the variable's value
22:25:50
LdBeth
anlsh: yes that’s why they’s a time problem because mit guile gambit also uses that extension, so please refer to 4.1 of geiser user manual
22:29:22
jackdaniel
LdBeth: while anlsh is excused as a newcomer for not knowing the channel topic you are not, please stick to it
22:34:21
anlsh
LdBeth: Drop me a heads-up in here if/once you send your first pm, I'm running erc right now and don't think it's functioning entirely correctly
23:41:06
jcowan
the loop syntax is LOOP WITH var = value AND var = value etc. (assignments not bindings) FOR (headvar . tailvar) IN list DO expr)
23:43:20
easye
lukego: sbcl20 is certainly doable for whatever time you have available. We start on Sunday night.
23:57:33
jcowan
the code is very interesting, but there was an explicit warning "adapt the loop to your Lisp: Maclisp, Interlisp, etc."
23:58:06
jcowan
I mean what the code does is interesting: a two-page Prolog interpreter using downward success continuations (recursions) instead of the usual upward failure (streams)
0:00:36
no-defun-allowed
(And I recall in a SICP video, Sussman stated he thought implementing logic programming with streams was simpler than with continuations.)
0:02:01
no-defun-allowed
Josh_2: Anything that's a specifier for a name (which I must check the correct term for), i.e. any string or symbol.
0:10:40
jcowan
But on the good side, the Nilsson article is there at https://github.com/rm-hull/ambages/blob/master/doc/twspi.pdf
0:11:19
jcowan
on the bad side, there are typos in the code; it obviously was retyped by someone who couldn't count parens
0:16:32
easye
ACTION is kinda reminded about the similarity to the shape of "correct" sexpr to that of a pattern in Go that will "live".
0:16:35
Josh_2
I defined a package, exported some symbols and then used that package in another but I have to refer to the functions within that package with a double colon.. <package>::<function> I was hoping the symbols would simply be imported and I could refer to them simply as (<function>) what have I oofed?
0:35:45
pjb
LdBeth: once I found a bug for a single wrong pixel on the screen (true stories, it was in 1986, the screens had only (* 512 348) #| --> 178176 |# pixels! ;-)).
0:37:30
jcowan
LdBeth: I messed with this program a few decades ago and a friend and I carefully counted the parens and figured out which ones to insert/delete. Unfortunately I lost the hard copy on which I did that.
0:38:11
jcowan
Lispers *with emacs* are magical beings etc. etc. Lispers without emacs, like me, have to recite "end of this, end of that" as we go. Not too hard really
0:40:07
LdBeth
jcowan: yeah that’s what I thought, figuring out parentheses printed on paper is not easy to me
0:42:19
Josh_2
clothespin: I am in the second package in the repl and I have to refer to my previous packages functions with <package>::<func> even though I have them in the :export clause of (defpackage )
0:43:52
clothespin
some lisps get buggy when redefining packages, try (symbol-package 'my-symbol) for debugging
0:49:47
clothespin
if you intern the symbol in the second package before putting it in your :use it could act like that
0:52:43
pjb
clothespin: you may want to use (com.informatimago.tools.symbols:check-duplicate-symbols)
0:54:46
clothespin
i usually restart sbcl as well but for the record i rarely had to do that with allegeocl
4:54:52
no-defun-allowed
Though elisp macros and CL macros are fairly similar, so it still might make sense in a CL context.
5:04:05
parisienne
yeah, the question I have is kind of generic and related to the appropriate use of macros. Not really about Emacs. Didn't want to risk a kick. What is ##lisp?
5:05:40
pjb
parisienne: have a look at: Casting Spels in Lisp Conrad Barski, M.D. http://www.lisperati.com/casting.html
5:06:23
beach
parisienne: Go ahead and ask. You will be told if your question is not appropriate for this channel.
5:15:45
parisienne
Well, I have been writing elisp, clojure and some CL for quite a bit now. Never touched macros, because most of the time functions just did what I wanted. Now to grasp macros better I am using my elisp config and trying to find things I can replace with macros. In this specific case I wanted to define a symbol/variable and set it to a value based on a file it reads at "compile" time. Here is the pastebin:
5:15:49
parisienne
I wanted to end up with either a (setq somevar "somevalue") or if the file doesn't exists, it should be (setq some-var nil).
5:16:53
pjb
parisienne: what would happen if the setq-if-exists form is evaluated without being compiled?
5:19:00
pjb
parisienne: so your question is quite emacs specific. In emacs lisp, like in CL, variables should be declared first. Using setq works, but since emacs 25 there is lexical bindings, so it is very preferable to define variables with defvar… (and of course, also use setq, since emacs lisp doesn't have defparameter, unless you define such a macro).
5:19:53
parisienne
the idea was just to have whatever symbol I define to nil. Still not sure about evaluation/compilation process in all the lisps. That is why I wanted to ask here. You can throw a CL example at me if you have anything.
5:22:21
parisienne
specification is basically, I pass in a symbol -> it should generate a "global" variable that gets a value from something else (in this case a file).
5:23:08
pjb
You say compile-time, but you only do things at macro-expansion time. And you don't say what happens at run-time.
5:24:27
parisienne
at the moment I just call the setq-if-exists in a function and after the call I use the passed in symbol in something else.
5:25:48
parisienne
Didn't think about that. But in my mind it should just override whatever value is/was there.
5:31:28
pjb
Well, it's rare to be wanting to load in a variable data at compilation-time. Configuration is something that is more often left for run-time and the end-user or administrator.
5:32:13
pjb
Compilation is usually completed long before the software is installed, on a different computer, by different people, than those who will install it, or use it.
5:33:17
pjb
While it's possible in lisp to inline data, when we save the program as an executable image, usually programs are distributed with resource files to be installed in specific places on the target system, and loaded at run-time.
5:36:43
parisienne
well, the idea for this started when I was writing a REST library in Clojure. What I wanted was to read all the endpoints definitions from a file and generate some base functions at compile time. I would have attempted the same thing in CL. Not sure if my reasoning makes any sense.
5:44:38
pjb
parisienne: when you have something like this, you actually have code in this file. There's no point in using a different system to load this code and compile it than normal lisp code.
5:44:50
pjb
parisienne: instead, write a macro to interpret this code, and put it directly in your sources!
5:46:32
pjb
I assume you have a function such as (generate (parse *data-read-at-compilation-time*)) Then you can write: (defmacro define-endpoints (&rest endpoints-definitions) `(generate (parse endpoint-definitions))) ; parsing will be simplier, since the lisp reader will have already tokenized it.
5:49:20
parisienne
pjb: yeah, exactly! This was exactly what I planned to do. But I didn't feel confident doing that yet.
5:50:23
pjb
Note the macro cannot be simplier. So you can gain confidence easily, by testing and debugging the parser and the generator independently.
5:50:54
pjb
(generate '((some definition) (and some other))) -> (progn (defclass …) (defmethod …) …)
5:53:15
parisienne
pjb: exactly. But you got my point and I assume it would not be unusual to see something like that in a library, correct?
6:21:07
montxero
I have a question, is it possible to construct an a-list where the cdr is a proper list?
6:28:49
pjb
montxero: (let ((attributes '())) (acons 'colors '(red blue white) attributes)) #| --> ((colors red blue white)) |# seems possible…
6:37:16
pjb
It's only the printed representation. Since there are no list and no a-list in lisp (paradox!), you need to interpret the bunch of cons cells as you wish.
6:37:40
pjb
When you consider a-lists, ((colors red blue white)) is interpreted as ((colors . (red blue white))).
6:37:55
beach
montxero: Maybe there is something I don't understand, but the CDR of an alist is always a proper list.
6:39:19
beach
My brain is too small to interpret what people utter in a way that contradicts what they actually did utter.
6:40:50
pjb
There's not much difference between an association and a property, it's just how they're represented: plist: (k1 v1 k2 v2 … kn vn) alist: ((k1 . v1) (k2 . v2) … (kn . vn)).
6:42:03
pjb
Furthermore, alist (the CL functions working with a-lists) can use keys of any class (there's a :test argument to use the equality you want), while plist (the CL functions working with p-lists) use only symbols (normally) and always use EQL to compare the keys).
6:44:26
pjb
fengshaun: note that both a-list and p-lists use the same number of cons cells, and are as efficient one as the other.
6:45:10
aeth
Scheme uses alists because they usually don't have a plist equivalent, and definitely don't portably. In CL, plists tend to be more common than alists.
6:46:15
aeth
The main disadvantage of plists is that you can't use map/mapcar, but you can loop by #'cddr and use a few other things
6:46:36
aeth
The main advantage of plists is that you can use &key in destructuring-bind, essentially treating plists like keyword arguments.
6:47:07
pjb
Well, you need more parentheses to write a-lists. But there's less risk of desynchronisation with a-lists than p-lists. If you miss two keys or values in a p-list, you can mix it almost entirely: (k1 k2 v2 k3 v3 k4 v4 v5) vs. ((k1) (k2 . v2) (k3 . v3) (k4 . v4) (nil . v5))
6:53:24
aeth
That can get confusing when the key and value are of the same type, usually a keyword in that case. It's the same issue with function calling with keyword arguments. You're basically requiring newlines for clarity at that point.
6:54:07
aeth
On the other hand, plists mirror keyword arguments so closely (see my previous two lines) so that's probably why they're more common than alists
6:56:50
montxero
beach: nice play the cdr of an a-list is always a proper list. I meant the cdr of an element of an alist
7:12:41
Cymew
aeth: Are you sure plists are more common? I find alists are mentioned so often as a suggested solution. I actually struggled to find a plist when I needed an example.