freenode/#lisp - IRC Chatlog
Search
21:27:25
elderK
I've defined a new type, with deftype, that specifies which symbols are valid for that "type."
21:27:43
elderK
(I read that like, enumeration values C-style - you know, symbolic names for integers, aren't the way to do things in CL?)
21:29:15
elderK
I was hoping that if I created an array of my type, the system would prevent me from say, setting an element of that array to some symbol outside of those specified by deftype. I've since learned about element type upgrading. So, the array accepts things of T.
21:30:45
sjl_
I've used integers before for things like emulator opcodes, to be able to easily look up things about them (e.g. their functions) in an array later.
21:30:45
elderK
Right, so you'd have functions that are used to mess with the array, and have the appropriate check-type in them, correct?
21:32:02
sjl_
Depending on your implementation you may get more or less help with the type checking. SBCL on (safety 3) is pretty helpful
21:33:32
sjl_
e.g. in SBCL if I do (deftype http-method () '(member get put post delete ...)) and then later (declaim (ftype (function (http-method string) t) query)) (defun query (method url) ...)
21:33:57
sjl_
and then later do (query nil "http://foo.com") later, SBCL will warn me that nil isn't an http-method
21:34:56
elderK
Just starting out you see. Finals are coming to an end, and I thought as a "learning project", I'd implement a (tough) assignment I did earlier in the year, but in CL.
21:35:53
sjl_
Yeah. If you want code review you can post it here and people are generally happy to critique things to varying degrees of nitpickiness
21:36:40
elderK
I imagine what I write at first will be pretty terrible. I hope to learn the better ways :)
21:37:20
elderK
It's like, there's a lot of "shortcuts' I'm used to using in C. None of those will work here.
21:38:39
elderK
This seems like a good little project. It's a solver for a cellular automata kind of thing. It's simple in that it doesn't need a lot of libraries and stuff. But not trivial. Seemed like a good fit :)
21:41:20
sjl_
Yeah, something nontrivial but not super involved is a good starting place. Especially something you've done before, so you're not trying to understand both the problem itself and a new language at the same time.
21:49:42
sjl_
One thing to keep in mind about shortcuts, is that a lot of CL people (e.g. me) care a lot about brevity of *ideas*, and don't care much about brevity of *characters*.
21:50:07
sjl_
e.g. to concatenate two bytes, a C programmer might do (a<<8)|b whenever they want to do that.
21:50:50
sjl_
someone like me would (declaim (inline concatenate-bytes)) (defun concatenate-bytes (high-order low-order) (logior (ash high-order 8) low-order))
21:52:02
sjl_
It's more characters to type "(concatenate-bytes ... ...)" than "...<<8|...", but instead of saying two things every time (shift, or) I'm saying exactly what I mean
21:53:36
sjl_
actually I did use dpb instead of the logior and shift when I implemented my cat-bytes :) https://github.com/sjl/cl-chip8/blob/master/src/emulator.lisp#L28
21:54:53
pfdietz
The cool thing about lisp here is not what the particular operators are, but that integers act more like integers. No 32/64/etc. limits.
21:55:31
sjl_
Yeah. Having actual numbers that act like numbers in my programming language is so refreshing.
22:13:56
elderK
Guys, when it is okay to do say `(,something ,something-else) vs. (list something something-else)?
22:14:14
elderK
I'm creating an array, and the dimensions are well, you know, part of the parameters.
22:15:34
sjl_
backquote is fine for that, yeah. It's good to keep in mind that backquote doesn't necessarily produce a fresh list every time
22:15:52
sjl_
So if you're going to be mutating the result, don't use backquote (or make sure to copy the whole tree first)
23:33:08
fiddlerwoaroof
iirc, one of the implementations switched to using structs as part of quasiquoting and broke some people's code walkers
0:05:19
luis
fiddlerwoaroof: you said you had to patch CFFI and Osicat to get static linking working. Will you be sending pull requests?
0:09:27
nyingen_
Do we have any particular libs or idioms for spawning external processes and doing I/O with them?
0:11:00
aeth
In particular, uiop:run-program or uiop:launch-program (the latter is newer and is capable of being async)
0:12:24
aeth
You probably want (uiop:launch-program name :input :stream :output :stream) and then you call uiop:process-info-input and uiop:process-info-output to get the two streams
0:18:56
nyingen_
I am writing some glue code. Last time I did this I switched to perl because CL's MySQL libs did not work for me. But this database is in sqlite, which I have used CL with before, so it should be all good
0:25:58
fiddlerwoaroof
If you're expecting something like (swap (atom 0) '1+) => (atom 1), that doesn't exist
0:40:00
elderK
Another dumb question: If I have a structure instance, and I copy it is, is the copy deep?
1:27:04
elderK
Guys, is there a better way to exit from inside a nested loop, other than using return-from?
2:24:53
elderK
I wonder if it's better to cache the exact dimensions of an array, rather than keep extracting it via array-dimensions
3:33:46
fiddlerwoaroof
elderK: equalp can be a bit surprising becaue (equalp #("asdf") #("ASDF)) => t
3:36:15
loke`
It's better to simply ignore its extentence since there are very close to zero cases where it does what you expect. And even in cases where you think it does what you expect, it doesn't.
3:36:42
fiddlerwoaroof
Or, perhaps more interestingly would be something like (== '(a 1) '(a 2) :key 'car :test 'eql) => t
3:38:55
fiddlerwoaroof
But, I think an equality function that worked on pairs of sequences and took a :key/:test pair like a bunch of other sequence functions would fit in nicely.
3:40:07
fiddlerwoaroof
If you wanted to be _really_ general you could add an argument for a function that took each of the provided arguments and mapped them to sequences, which were then compared elementwise using :key/:test
3:40:52
fiddlerwoaroof
But, I think the ultimate thing to realize, is that equality is highly domain-specific
3:42:43
fiddlerwoaroof
luis: I wonder if it would be better to split the asdf parts of cffi into a new system
4:01:49
elderK
equalp uses char-equal for comparing strings, right? And that is case insensitive. char= /is/ case sensitive.
4:06:08
fiddlerwoaroof
elderK: yeah, which is why I've never really used equalp for anything, except as a hash-table test
4:12:41
elderK
But, yeah, I noticed that it would suck if, for example, you had an array of say, strings.
4:13:38
elderK
Had quite a bit of fun today just, tinkering away on my first "not just screwing around" program in CL. I'll probably throw it all away - I'm learning more as I go.
4:16:01
fiddlerwoaroof
It's not really intended to be beginner-level documentation, which partially accounts for its structure
4:16:07
elderK
I'll get used to it. But, sometimes, it's like... you wind up in the glossary or in say, some docs for something but the important info you are looking for isn't in either place. Like, I was trying to learn more about &key and &optional parameters. defun just says "lambda list" So, glossary. "Ordinary lambda list." Glossary. Bounced around for ages, until I wound up in the right place :P
4:17:17
fiddlerwoaroof
italicized links go to the glossary, which generally means I avoid clicking them unless I'm really interested in what a word means
4:17:39
elderK
I do have a question regarding setf types. I've noticed that there is defsetf. But, in other projects, I swore I saw them using something like (defun (setf whatever) ...). Looking around in CLHS, I got a bit confused. Like, how do you define a setf expander?
4:20:06
elderK
Sometimes, it has more like, examples. Seemed more tutorially, but not /too/ tutorially, if you get my gist.
4:21:07
elderK
Aye. I only use it to kind of get a better... grasp. When that's done, I zoom back to CLHS.
4:23:10
fiddlerwoaroof
I bind it to Command-Alt-\ and I have easily accessible documentation for everythign I need
4:24:59
elderK
I can't believe I didn't know about this! It has docsets for all the things I use! This is *great*
4:39:12
fouric
drmeister: in case you weren't aware of it already, here's another CLASP: https://www.radioeng.cz/fulltexts/2011/11_04_880_889.pdf
4:41:33
beach
When I name things, I try to introduce a different spelling, or at least verify that Google does not return anything interesting first.
4:44:33
beach
I will make an exception with the second version of Gsharp. It will use a name that is in line with a long tradition for score editors: Clovetree.
4:47:45
beach
Of course, I need to make sufficient progress on SICL first, so that I can hand it over to others. :)
4:55:41
no-defun-allowed
has anyone written a program that tries to generate proofs (or new facts) given some facts?
4:56:09
elderK
fiddlerwoaroof: The only problem with Zeal, for me, is the same problem with most things today that integrate CEF or Webkit in some way: It means I'm effectively running a zillion instances of a web browser. :|
4:56:46
no-defun-allowed
i know people have used programs to assist with proofs, but i think letting the program try to generate some itself would be faster
5:02:32
no-defun-allowed
beach (IRC): was G# the least used note on the internet when you named Gsharp?
5:12:32
no-defun-allowed
i thought about that but i haven't seen people generate new rules like that
5:15:43
fiddlerwoaroof
"The little prover" is a really interesting nice introduction to the underlying system
5:19:10
LdBeth
#'no-defun-allowed: in prolog you can define relations and ask what’s the relation between two term
5:48:47
no-defun-allowed
yes, they're only the same in the --horrible and out of tune-- equal temperament tuning
5:51:39
no-defun-allowed
(it's annoying that all the nice ratios like 3:2 for a perfect fifth are off)
6:12:13
elderK
Guys, question: How am I meant to parse: " defgeneric function-name gf-lambda-list [[option | {method-description}*]]"
6:12:28
elderK
As far as I read that, it says we can have only /one/ option. But we can have zero or more method-descriptions.
6:12:52
elderK
But the CLHS states you can have multiple options - as long as each is specified once?
6:51:56
beach
It is quite confusing, but I think if one takes the time to read it, it might become clear. :)
7:58:47
cupholder
I'm doing the exercises from Norvig's PAIP to learn CL, and noticed something weird. He says compilation makes functions 300+ times faster, but trying his "f" function on an input of a billion (to see the running time difference on a modern computer) gives me 4.919s for the interpreted version and 4.918 for the compiled version.
8:00:13
cupholder
To make sure I wasn't crazy, I wrote a basic recursive fibonacci function and timed it. It came out to 4.063s for the interpreted version and 4.064s for the compiled version. In both cases, I ran the function with the timer after defining it in the repl, entered (compile 'f) or (compile 'fib), and ran it again.
8:08:32
cupholder
The explicitly-compiled version runs with the same time on subsequent runs. Did SBCL produce a different binary for the same code? Is it non-deterministic?
8:11:35
jdz
I don't know. I'd rather forget a thing or two now and then than one bit flip in my brain crash the whole thing.