Search
Tuesday, 26th of September 2017, 9:54:10 UTC
9:56:10
|3b|
other notable features are that the runtime spec doesn't have any data for 'foo2 in toplevel, or 'c in bar-type, and similarly, the person-written code doesn't write 'baz or 'd, but code is generated for them (and no code is written to write default values for other slots that are then overwritten by user code)
10:06:44
pjb
Anyways, this is basic compiler stuff, so you know what to read and study…
11:14:31
theemacsshibe[m]
What's a good way to save an object? I've just been formatting ~s objects to files and using read to read them again but using format feels a bit odd.
11:15:03
Xach
theemacsshibe[m]: that is not so bad if it works
11:15:23
Xach
theemacsshibe[m]: i use cl-store for more complex things
11:15:27
theemacsshibe[m]
I suppose so Xach, but it still feels wierd.
11:15:46
Xach
theemacsshibe[m]: it is good about storing instances, structures, hash tables, etc.
11:15:52
theemacsshibe[m]
(btw feel free to replace "object" with "nested lists")
11:16:09
theemacsshibe[m]
Alright, I'll go hit the docs for that. Thanks.
11:16:30
Xach
the api is something like (cl-store:store object file) and (cl-store:restore file)
11:16:42
Xach
i have not yet had to look any deeper than that
11:17:26
theemacsshibe[m]
Docs suggest that, seems pretty straightforward. I'll install Quicklisp in the morning.
11:19:22
Shinmera
If it's just for configuration files, there's also Ubiquitous
12:25:30
Posterdati
is there a way to override the standard structure constructor?
12:26:43
flip214
Posterdati: the name, or the complete function? both is possible.
12:26:54
flip214
just define your own function for the latter.
12:27:21
specbot
http://www.lispworks.com/reference/HyperSpec/Body/m_defstr.htm
12:27:56
Posterdati
I read that, but how can I instantiate the struct? make-instance?
12:29:59
_death
I think the nil constructor is more useful when the :type is list/vector
12:38:01
specbot
http://www.lispworks.com/reference/HyperSpec/Body/f_alloca.htm
12:40:14
knobo
Can I set up some hook in a bt-thread that will be run in that thread on a signal?
12:50:33
Posterdati
beach, flip214 thanks
13:36:03
didi
Why does https://github.com/tarballs-are-good/quickutil/blob/5adb3463d99095145325c4013117bd08a8f6cac2/quickutil-utilities/utilities/sequences.lisp#L118 declare FLET functions as dynamic-extend? I only know about dynamic-extend because of Costanza's c.l.l. post.
13:36:49
didi
Sorry, not FLET functions, but LABELS.
13:37:29
beach
Probably hoping they will be allocated on the stack.
13:38:14
didi
beach: So I am guessing for performance reasons?
13:39:40
lieven
and in old speak to state that they're downward funargs. that also enables some optimisations.
13:40:21
didi
lieven: "funargs"? Sounds like a fun word.
13:41:07
lieven
we call them closures nowadays :)
13:55:17
didi
stylewarning: I am interested in why did you declare the labels functions as dynamic-extend in `equivalence-classes'.
13:56:39
stylewarning
didi: generally if I don’t want to save the function objects created by labels, I’ll declare them as dynamic extent, so the compiler knows it can allocate and free the memory right away
13:59:23
stylewarning
didi, have you managed to get the function to work?
14:03:54
didi
stylewarning: I didn't have the time yet, but I'm working on it.
15:27:35
mrpat
I have a question about parenscript and Ben Hyde's plot-window in particular...
15:27:52
mrpat
(defmacro ps-eval-in-client (&body parenscript-forms)
15:27:54
mrpat
(let ((body `(progn ,@parenscript-forms)))
15:27:55
mrpat
(when *catch-eval-in-client-errors*
15:28:02
mrpat
(interpolate "[Error: ${(@ e message)}]"))
15:35:39
didi
stylewarning: What do you think? https://paste.debian.net/hidden/bcf2c844
15:38:59
z3t0
is there a construct in lisp where i can do x and then evaluate if and then do x if the if evaluates to false?
15:39:45
z3t0
here's what i have, http://sprunge.us/eZNY Except I want the input to precede it as well
15:41:03
beach
(progn x (unless condition x))? Is that what you mean. I am having a hard time understanding what you want.
15:41:21
beach
Perhaps you could be more explicit.
15:41:45
z3t0
okay so essentially I want to loop a request to the user for some input, as long as the input is not valid
15:42:15
beach
(loop for input = (read) until (validp input))
15:43:51
z3t0
but I also want to repeat the call to (format)
15:44:23
beach
(loop for input = (progn (format "hello") (read)) until (validp input))
15:46:13
z3t0
okay so I have a function like (defun x (b a ) (b a )) where b is a function itself
15:46:26
z3t0
but i am getting an error saying b is not defined in the body of x
15:46:44
dlowe
z3t0: you have use (funcall b a)
15:47:01
z3t0
too much javascript has messed me up
15:48:49
z3t0
Just so I understand, the reason for funcall is because I am storing a function inside a variable?
15:56:31
z3t0_
okay so I have (until (funcall x y )) which exits the loop as needed but then how do i return y there?
15:57:44
z3t0_
alright thanks, it feels like loop itself is its own language haha
15:58:32
dlowe
It pretty much is. These days, they're called DSLs - Domain Specific Language
16:05:30
z3t0_
Any recommendations for parsing floats from strings? There seem to be many different ways it is done?
16:05:37
z3t0_
maybe alexandria has something
16:05:48
dlowe
there's a parse-number library in quicklisp
16:06:07
dlowe
if you trust your input, you can use read-from-string
16:08:50
dim
of course, never trust your input
16:11:08
z3t0_
in this case its just for debugging so i should be ok
16:20:13
White_Flame
if it's untrusted, I tend to match against a regex, then call READ
16:20:16
z3t0
is it possible to check if an argument is given?
16:20:26
z3t0
say I have (defun x (&key b))
16:20:27
White_Flame
slow, but functional
16:20:46
dim
a regexp is a poor's man parser
16:20:48
z3t0
I am trying to write an (if b (something) (else)) but it seems to complain that the form is incorrect
16:21:47
dim
z3t0: &key allows other forms with 2 and 3 parameters, check it out
16:22:27
Bicyclidine
but if b = nil means it's not given, it shouldn't "complain"
16:22:33
dim
http://www.lispworks.com/documentation/HyperSpec/Body/03_da.htm
16:22:35
Bicyclidine
more information on the "complaint" might help clarify
16:22:53
dim
http://www.lispworks.com/documentation/HyperSpec/Body/03_dad.htm even, z3t0
16:23:22
z3t0
this is the error but isn't much help so i didn't include it http://sprunge.us/OBUa
16:23:29
z3t0
I'll try what Bicyclidine suggested
16:24:23
z3t0
ah never mind i had a small syntactic error
16:25:27
Bicyclidine
that's perfectly helpful, you can see you have :type-converter set up as a keyword parameter
16:31:19
dim
the octet sequence #(252 98 110 101) cannot be decoded.
16:31:47
dim
using uiop:run-program :output :string here, is there a way to somehow plug babel or something in there?
16:31:51
didi
I'm back. If anyone want to comment on <https://paste.debian.net/hidden/bcf2c844>, please.
16:32:07
didi
The `subseq' call makes me uneasy.
16:35:50
_death
https://common-lisp.net/project/sequence-iterators/ is useful for this
16:40:39
z3t0
can anyone recommend a resource that explains how to use loop but is also easy to approach for beginners
16:41:46
_death
the chapter in practical common lisp?
16:52:12
didi
What would be an exhaustive list of sequence types?
16:53:17
_death
didi: there is no such list
16:54:45
didi
I thought of using `listp' and `vectorp', but then I remembered SBCL has extensible sequence types.
16:55:10
specbot
http://www.lispworks.com/reference/HyperSpec/Body/t_seq.htm
16:59:25
stylewarning
didi: you should SETF the nreverse
16:59:36
stylewarning
(SETF X (NREVERSE X))
17:00:32
didi
stylewarning: Even though I am passing it as an argument?
17:02:16
stylewarning
If X is the list (1 2) for example, X will always point to the cons (1 . ...)
17:02:22
z3t0
I am creating a program in lisp that stores a set of images with latitude and longitude coordinates for the center of the images
17:02:40
stylewarning
So if you NREVERSE, it may be that X still points to the same cons cell
17:02:48
didi
stylewarning: But I am not passing X, I am passing (nreverse X).
17:02:59
stylewarning
(NREVERSE X) will return (2 1) but X is still pointing to (1 . ...)
17:03:10
z3t0
I need to create a system so that I can store all of the images with lat and lng and then write a function that takes lat and lng and then finds the closest image
17:03:11
_death
stylewarning: uh, no... it is passed to MAP.. but then, there shouldn't be an NREVERSE anyway, unless it's meant to be a destructive operator
17:03:23
z3t0
Can anyone suggest a method / data structure for this
17:03:38
stylewarning
Sorry, that’s right. The LET inside of the call to MAP threw me off
17:03:53
copec
Is there a way to query by "Pasted by" on paste.lisp.org?
17:03:54
stylewarning
In that case I recommend lifting the LET out of the MAP (:
17:04:05
didi
_death: I used `nreverse' for performance reasons, because `subseq' creates a new sequence anyway.
17:05:09
_death
didi: no, it's actually OK, since SUBSEQ will always create a new sequence
17:05:10
stylewarning
didi this isn’t universal among all lisp users but I prefer to prepare my data before executing on it, especially if it contains somewhat complicated logic
17:05:35
didi
stylewarning: Makes sense.
17:05:46
stylewarning
Here you have the logic of slicing and reversing, and it’s nice to make that evident before mapping (IMO)
17:08:06
_death
z3t0: there is a spatial-trees library
17:08:51
_death
z3t0: if you're using a database, it is also possible that it has a solution for that
17:09:05
z3t0
I'm not currently using a database but am actually thinking about it
17:09:38
z3t0
my thoughts was using something like redis with some prefetching of nearby data
17:12:28
_death
z3t0: it seems redis added spatial queries.. guess I'll have to update my lredis library at some point in the future :)
17:14:25
_death
silly how redis uses an ad-hoc protocol for its commands
17:20:40
z3t0
how can i create a 2d array indexed by floats?
17:20:53
z3t0
So in my example I have latitude and longitudes for each image
17:25:00
_death
you don't.. array indices are integers
17:28:20
didi
I wish I had a better form than (if predicatep (do-something datum) datum).
17:29:38
oleo
that's exactly what if is for
17:30:27
didi
It is more about the concept. I want to do something to datum only if predicatep.
17:30:58
didi
But then `when' evals to nil.
17:31:00
shrdlu68
(or predicatep (do-something datum))
17:31:25
didi
shrdlu68: It evals to nil too.
17:31:44
didi
Actually, it evals to `predicatep'.
17:32:47
didi
So I want datum if (not predicatep).
17:33:14
oleo
(when (not predicatedp).....
17:33:37
didi
I think it still doesn't do what I want.
17:34:12
didi
That's what I've been doing, yes.
17:34:31
oleo
but we don't get the point
17:35:34
_death
(funcall (if condition #'do-something #'identity) datum) ; if you like convoluted code
17:35:55
oleo
(progn (when (not predicatedp) datum) (dosomething predicatep)) or if you are in an implicit progn would do too
17:36:22
oleo
err dosomething datum i meant yea
17:37:18
didi
Maybe I should write a macro like (do-when predicatep fn datum). Doesn't look better, tho.
17:38:14
_death
didi: indeed, stick with the IF
17:38:42
z3t0
I'm trying to understand spatial-trees and I get the idea of it but am a bit confused regarding implementation
17:39:11
oleo
what is it about actually ?
17:39:41
oleo
someone is planting on the moon or so ?
17:40:37
z3t0
its a tree data structure that is used for spatial data, eg location
17:41:55
oleo
and why you need a tree for that ?
17:43:12
z3t0
It's a good way to do searches based on space
17:43:30
z3t0
eg if you want to find the number of object within a certain unit
17:43:39
z3t0
Though I'm doing a terrible job explaining it ..
17:43:51
z3t0
Can anyone help me understand https://github.com/rpav/spatial-trees/blob/master/tutorial.lisp line 30
17:45:34
z3t0
actually nevermind i think i've figured it out
17:54:37
z3t0
how do i use the package "rectangle" from https://github.com/rpav/spatial-trees/blob/master/api.org
17:55:03
z3t0
I am using quickload which gives spatial-trees as an object but i cant figure out how to access the rectangles package
17:58:10
Bicyclidine
it looks like there should be a rectangles package as part of the spatial-trees system?
17:59:02
oleo
it should be already there try (find-package :rectangles) or so
18:00:17
oleo
https://github.com/rpav/spatial-trees/blob/master/rectangles.lisp
18:00:49
oleo
https://github.com/rpav/spatial-trees/blob/master/spatial-trees.asd
18:02:43
oleo
https://github.com/rpav/spatial-trees/blob/master/package.lisp
18:04:50
oleo
https://github.com/rpav/spatial-trees/blob/master/api.org and read that one too
18:05:08
oleo
it informs you of symbol conflicts between the rectangles and the spatial-trees package
18:05:20
oleo
and how you can resolve it
18:14:22
oleo
did you find your package ?
18:17:59
z3t0
i used a defpackage and used :use rectangles
18:18:07
z3t0
but I can't seem to do that for spatial-trees.nns
18:18:32
oleo
just look thru the sources
18:19:42
z3t0
I think i just need to figure out how packages work
18:20:13
oleo
you need to figure out asdf
18:20:30
oleo
with asdf you only have systems
18:20:43
oleo
some components will be files some modules some other systems
18:20:55
oleo
the files may contain pacakge definitions
18:21:08
oleo
by loading systems you get the packages but there's no way to get the packages alone via asdf
18:21:28
oleo
in order todo that you have to know in which file it is and load it
18:21:45
oleo
or at least know which systems contain it as a component and load one of the supersystems
19:39:54
dxtr
how do I reinstall a package with quicklisp?
19:40:27
XachX
Like, replacing what is there?
19:40:31
dxtr
XachX: Optimally I just want to force a rebuild
19:40:44
oleo
(quicklisp:quickload :blah :force t) ?
19:40:48
XachX
Oh. There are many ways. You could use asdf directly.
19:41:05
oleo
(asdf:load-system :blah :force t) sorry
19:41:05
dxtr
How would I achieve this with asdf?
19:41:06
XachX
Deleting fasls is an option too.
19:41:54
oleo
well if you deleted some of your directories in the quicklisp branch, just do another load with quicklisp and it will redownload some stuff
19:42:26
dxtr
My actual problem is that cl-sdl2 broke and I suspect it might be because I have updated sdl
19:42:39
dxtr
So I just wanted to rebuild it and see if that fixes it
19:51:44
White_Flame
dxtr: rm -rf ~/.cache/common-lisp/
19:52:11
White_Flame
and if it's early build stuff, rm -rf ~/.slime/fasl/
19:53:54
White_Flame
quicklisp itself doesn't hold anything but the project sources, so you don't need to erase & redownload those, unless you suspect your filesystem is corrupted or something trampled the data there
19:55:56
oleo
quicklisp/dists/quicklisp/software/
19:56:06
oleo
i sometimes deleted some stuff
19:56:52
oleo
i instead should have learned howto register stuff and unregister....
20:17:26
iqubic
So a macro can only consist of a single body form? Which is expected to be the backquoted replacement code?
20:17:45
dlowe
it doesn't have to be backquoted
20:17:52
dlowe
backquoting is just convenient.
20:18:09
iqubic
How does a macro work when not backquoted?
20:18:18
dlowe
because lisp is made of data, not text
20:18:18
Shinmera
A macro can consist of any number of body forms, but it can only /return/ a single one.
20:18:33
dlowe
so a macro can return any list
20:18:53
iqubic
Oh. Right you could use list and quote all the elements
20:19:41
dlowe
(defmacro infix (&rest args) (list (second args) (first args) (cddr args))
20:20:24
dlowe
;; TODO: make work with more than three arguments
20:22:11
iqubic
Can a macro have multiple s-exps in the body, so long as it only returns a single s-exp?
20:22:50
Shinmera
Read what I said above.
20:23:15
dlowe
iqubic: yes. It can also return a PROGN form, so you can still do multiple things from a macro
20:25:35
pjb
iqubic: nope, you can define macros with multiple body forms.
20:25:39
iqubic
If I quote something, it returns a symbol, right?
20:26:08
iqubic
So 'foo returns the symbol foo?
20:26:57
Shinmera
Quote prevents evaluation, so it returns a literal.
20:27:30
pjb
(defmacro one-of ((&body body) &rest other-bodies) `(case (random ,(1+ (length other-bodies))) (0 ,@body) ,@(let ((i 0)) (mapcar (lambda (body) `(,(incf i) ,@body)) other-bodies)))) (macroexpand-1 '(one-of ((print 'hi)) ((print 'fizz) (print 'buzz)))) #| --> (case (random 2) (0 (print 'hi)) (1 (print 'fizz) (print 'buzz))) ; t |#
20:27:49
pjb
iqubic: if you quote something it returns something.
20:28:00
iqubic
What is the difference between a symbol and a literal?
20:28:08
pjb
'42 --> 42 '(not a symbol) --> (not a symbol)
20:28:25
iqubic
pjb, that's not explaining it.
20:28:27
pjb
a symbol is a symbol; a literal is what is quoted (or self-evaluating).
20:28:30
dlowe
iqubic: remember I mentioned lisp is made of data objects and not text?
20:28:47
dlowe
iqubic: quoting returns the data objects passed into it
20:28:53
oleo
it has an underlying datastructure
20:28:57
dlowe
iqubic: instead of attempting to evaluate it
20:29:03
pjb
'#S(point :x 1 :y 3) --> #S(point :x 1 :y 3)
20:29:23
oleo
it is woven into the implementation at the time of it's extantiation
20:29:26
dlowe
iqubic: '(+ 1 2) => (+ 1 2) while (+ 1 2) => 3
20:29:54
iqubic
'(+ 1 2) is a list containing three symbols?
20:29:56
pjb
iqubic: Common Lisp: A Gentle Introduction to Symbolic Computation http://www.cs.cmu.edu/~dst/LispBook/ http://www-cgi.cs.cmu.edu/afs/cs.cmu.edu/user/dst/www/LispBook/index.html
20:30:09
pjb
'(+ 1 2) is a list containing one symbol and a list.
20:30:23
pjb
'(+ 1 2) is (quote (+ 1 2)) quote is a symbol (+ 1 2) is a list.
20:30:50
dlowe
iqubic: it's a list containing three "atoms"
20:31:07
pjb
(loop for item in ''(+ 1 2) do (format t "item: ~S is a ~S~%" item (type-of item)))
20:31:39
pjb
(+ 1 2) is (read as) a list that contains something that depends on the *read-base*.
20:31:57
pjb
(+ 1. 2.) is a list that contains a symbol + and two fixnums 1 and 2.
20:32:28
pjb
If the *read-base* is 2. then (+ 1 2) is read as a lists containing two symbols, + and \2, and a fixnum: 1.
20:43:13
iqubic
Macros are really confusing me right now.
20:46:21
iqubic
And I'm not understanding them.
20:46:47
oleo
you don't do them until you have to
20:53:49
iqubic
Well, I solved my issue. I had forgotten to unquote a variable name in my macro expansion.
21:06:48
iqubic
Now that I have successfully created a macro, I understand how and why you use them.
21:18:54
Fare
congrats, you're now a lisper.
21:23:52
fe[nl]ix
iqubic: now you're in for a lifetime of disappointment
21:37:31
iqubic
I finally got my macro to work.
Tuesday, 26th of September 2017, 21:54:10 UTC