freenode/#lisp - IRC Chatlog
Search
9:14:21
pve
Good morning! A terminology question: is it correct to say that a cons is a "persistent data structure", whereas something like a hash table (at least in CL) is not?
9:16:26
flip214
or do you mean that the in-memory layout is fixed for a CONS cell, but a hash table can change in size?
9:17:09
phoe
if it's https://en.wikipedia.org/wiki/Persistent_data_structure then neither conses nor hash tables in CL are like that
9:18:53
phoe
you can treat both of them as functional data structures which means not mutating them; this means consing up new lists and sharing structure wherever possible, and making new hash tables instead of modifying old ones
9:18:56
pve
yeah, I was looking for a name to distinguish between those kinds of data structures, which at least to me, seem different in how they are usually used
9:21:34
phoe
in Lisp, it's more of a contextual question, especially since conses are CDTs and not ADTs
9:21:49
pve
ok, suppose we don't mutate conses, would "functional data structure" be the correct term?
9:26:46
pve
I'm looking at https://en.wikipedia.org/wiki/Persistent_data_structure and also https://en.wikipedia.org/wiki/Purely_functional_data_structure
9:28:33
phoe
a singly linked list is not such a structure because the result of (CDR '(1 2 3)) does not refer to (1 2 3) anywhere
9:33:51
phoe
OK, "preserve" means a different thing in this context; it doesn't mean explicitly refering to them, it means that the previous values are unchanged
9:38:59
phoe
every purely functional data structure is persistent, but is it true that every persistent data structure is also purely functional?
9:45:09
treflip
Persistent data structures may be implemented in imperative style. There is a great book "Purely Functional Data Structures" by Chris Okasaki, it has a clear explanation of these things in its first chapter IIRC.
9:45:27
sm2n
it's a bit odd because these categories kind of cut across both implementation/interface
9:46:33
sm2n
purely functional is a property of the interface, in that the interface doesn't mutate its arguments
9:46:51
sm2n
persistent is basically an optimization, where shared structure is used wherever possible
9:49:56
treflip
In his book Okasaki divides data structures into persistent and ephemeral, meaning that persistent data structures kinda provide access to their previous states, and ephemeral don't.
9:53:35
pve
treflip: you mean that when you add something to a red-black tree, you get a new tree back?
9:56:21
beach
If you can't access the old three, there is no great difference between a functional an imperative data structure.
9:57:20
beach
Imperative: (insert <thing> <tree>) Functional: (let ((tree (insert <thing> <tree>))))
9:58:00
beach
So, yes, a new tree would be returned, probably sharing structure with the previous one.
9:58:33
beach
But then, a red-black tree is not an abstract data type either, so it's not a great example.
9:59:13
beach
The abstract data type would be a dictionary with a totally ordered key domain, or an editable sequence.
10:00:04
beach
A red-black tree is a way to implement those abstract data types, and the very definition of a red-black tree seems to require destructive modifications to maintain a balanced tree.
10:02:57
beach
I mean, it is obviously possible to make a red-black tree "functional", but it may reduce possible sharing then.
10:03:41
beach
It is obviously possible, because you can always clone the original tree and make a destructive modification in the clone.
12:17:42
Josh_2
I Know that the Atlanta Functional Programming group went through the AMOP but the examples given in the book seem quite trivial
12:23:21
heisig
Josh_2: Good question. I think there is no comprehensive MOP guide (yet?), so you have to learn from other people's code.
12:25:31
heisig
Which raises another good question: What is everyone's favorite code that makes heavy use of the MOP?
12:34:49
shka_
folks, i am trying to build a strongly independent on seed (and hopefully reasonably fast) hash function for lists of (unsigned-byte 64)
13:49:02
mseddon
Can I just say, I am absolutely blown away with SBCL performance on a Raspberry Pi Zero. It's easily more responsive than anything else I've used.
13:49:31
mseddon
(and by anything, I mean any other scripting language- I have not compared different lisp environments).
13:53:50
beach
mseddon: Ah, but Common Lisp is not a "scripting language", which explains why SBCL has much better performance. Instead Common Lisp is a general-purpose programming language, so good implementations must be sufficiently fast to compete with implementations of other general-purpose languages.
13:54:49
mseddon
beach: Yes, I'm aware, (actually returning to lisp from a 20 year haitus), I looked in horror as I sent that and knew someone would raise it :)
13:58:26
beach
That's not all there is to it. Designers of so-called scripting languages are often incompetent when it comes to language design and compiler technology. Not so for the very smart and very knowledgeable people who gave us the Common Lisp standard.
13:59:06
mseddon
beach: absolutely true. nearly every 'successful' language is just a crap recursive descent compiler that emits crap stack bytecode. mmm. cache trashing.
14:00:17
mseddon
v8 is quite interesting, but javascript braindamage definitely limits it excessively. Seems more like a self compiler really.
14:00:52
remexre
also impressive to me, SBCL on my pinebook pro also blows most compiled languages out of the water on compile speed, even when building binaries with a fresh sbcl process
14:01:55
remexre
yeah, I usually like Rust and Haskell a lot, but it's been excruicating to develop for them on that machine
14:03:24
mseddon
remexre, it is a rocket engine compared to Scala once you start depending on libraries that abuse the type system.
14:05:10
jackdaniel
ACTION sends a polite reminder, that this channel topic is common lisp [[ a friendly smile at the end -- :-) ]]
14:11:28
ajithmk
Are keywords scoped to a package? If there is symbol in a package, say s, we use it in another package like package:s or package::s. But if s is keyword, : get's in the way? Like package::s or package:::s?
14:14:24
ajithmk
So when reader encounters :foo in a package it interns FOO in keyword package. So :foo is available in any other package?
14:16:37
jackdaniel
it is defined that implementations are free to give meaning to that, but that would be by definition not portable
14:27:24
phoe
(let ((form (read *repl-stream*))) (cond ((eq form :command) ...) ... (t (print (eval form)))))
14:28:49
jackdaniel
also, if you had wanted to do what you've mentioned you want to, you'd want symbol-macrolets, not functions
14:28:55
mseddon
keywords as functions trip me up a lot on Clojure, but I guess that may be also hurt because it's a lisp-1
14:29:37
jackdaniel
even older implementations (most notably genera), started commands with a comma which is less ambigous
14:30:30
mseddon
Does CLIM use , for commands too? I seem to remember it has command tables like genera, but I am incredibly rusty.
14:32:01
jackdaniel
ldb: yes, but listener combines both the repl and the command processor (vide clim-listener, slime)
14:47:05
mseddon
looks like a toss up between check-it and cl-quickcheck, do people have any preferences?