freenode/#lisp - IRC Chatlog
Search
19:47:15
shka_
if anyone is interested, that's how i do it https://github.com/sirherrbatka/cl-data-structures/blob/0e5df4640ade420305f2535453848a2bd67a5545/src/utils/macros.lisp#L318
19:50:11
saturn2
i don't see the problem with eval-always-ing your class definition if you want to use it at compile time
19:51:59
shka_
it wanted to call it lol (let over let) but in reality it is usually over lambda so it is let over let over lambda
20:03:52
ck_
A higher amount than usual of lisp on hacker news at the moment. Have I missed some anniversary?
20:05:02
aeth
ck_: I think people are just seeing what's getting karma and reposting old things for karma
20:06:23
aeth
Repost this one, "Beautiful Online SICP" (762 points in 2017): https://news.ycombinator.com/item?id=13918465
20:08:44
aeth
Mezzano was posted 19 days ago so that is probably too soon. Some others here could think of something, I'm sure, though.
20:09:31
aeth
borodust: You could try doing a Show HN of trivial-gamekit since HN's hivemind is filling its front page with Lisp articles right now. i.e. https://borodust.org/projects/trivial-gamekit/
20:31:09
Josh_2
hmm, so I can't use (setf (funcall accessor instance) "abc") :( Is there a way I can get around this?
20:42:31
aeth
borodust: ck_ is right, the front page is currently full of Lisp stuff for some reason. https://news.ycombinator.com/news
20:51:31
_death
it will only work if there's a function called (setf accessor) and the two last arguments transposed, assuming "abc" is the new value
20:51:35
dialectic
However you're passing accessor in, pass this instead: (cons #'accessor #'(setf accessor))
20:58:42
Josh_2
Okay that worked, but my logic was broken anyways. Thanks _death I'll fix when I get back
21:09:19
_death
Josh_2: in this case it may be enough just to read a list of initargs and (apply #'make-instance 'data-entry initargs)
21:16:05
dialectic
#| stuff |# is also used for (nestable) comments, so careful with that too if you're making a dispatch character.
21:19:51
MichaelRaskin
Well, borderline: they use that it looks || in code and ignore the fact that it has empty name
21:21:33
stacksmith
Yeah... It's kind of hard to enter it any other way than ||, so as much as I want to object to it, I can't find a good reason... I suppose (find-symbol "") to get '|| may be a little confusing.
21:43:23
fiddlerwoaroof
By the way, shka__, data-lens now has "real" Van Laarhoven lenses: https://github.com/fiddlerwoaroof/data-lens/blob/master/lens.lisp#L83-L127
21:45:44
fiddlerwoaroof
This, so far, is the public interface: https://fiddlerwoaroof.github.io/data-lens/The-data_002dlens_003cdot_003elenses-package.html#The-data_002dlens_003cdot_003elenses-package
21:48:04
fiddlerwoaroof
The advantage of this is that you don't need to depend on a specific lens library to provide lenses: a lens is just a function that works in a certain way and any such function will be compatible with DATA-LENS.LENSES:VIEW, DATA-LENS.LENSES:SET, and DATA-LENS.LENSES:OVER
21:48:29
fiddlerwoaroof
Also, these functions use the "traditional" names for the lens operations, so they'll be more familiar to people coming from other languages.
22:26:31
dialectic
lenses seem vaguely inappropriate for a language like common lisp where I can iterate over slot values or use symbols to set arbitrary slots.
22:33:51
saturn2
common lisp doesn't come with a convenient built-in way to make modified copies of arbitrary objects without mutation
22:34:38
oni-on-ion
R and Julia have things called 'DataFrame' which is kind of like a lense into arbitrarily large data sets, but less about code and more about data (afaik)
22:38:12
dialectic
saturn2: I mean, sure. But how is that any worse or better than a "lens"? You could use one macro, for all cases.
22:38:35
dialectic
Admittedly my functional-fu is weak in this area. I know this won't work for the "applicative" pattern.
22:48:02
fiddlerwoaroof
Lenses are really nice, because if you have two lenses, simple function composition composes the "pointers"
22:49:18
fiddlerwoaroof
And, thy are just "values", so you can pass them around, allowing you to separate "what" a function operates on from the operation applied.
22:50:11
fiddlerwoaroof
Accessors, etc. are handy and, to some degree, overlap with lenses but a significant difference is that setting a lens copies the underlying object, while setfing an accessor mutates it: both have their place, but lenses preserve encapsulation a bit better
0:26:35
vsync
is there anything already to simplify the situation where one wishes to define a protocol and specify methods which may be readers but without imposing a slot requirement?
0:26:54
vsync
this may go into the question of protocol declaration which I'm sure has been discussed before
1:11:05
Ankhers
Hey, I'm just getting started with lisp. Can anyone suggest some books, blog articles, whatever else that they consider to be essential learning materials?
1:11:27
vsync
pjb: naturally but wondering if there is a nicer way that allows for writers and for grouping with protocol (classes)
1:12:14
pjb
vsync: there are various macros to deal with the problem of interfaces, with various features, in systems such as asdf and others.
1:12:28
vsync
something like (defclass foo () ((bar :allocation nil))) modulo of course the redundancy of slot-/accessor-name
1:12:50
vsync
though I'm realizing this may encompass a larger question so I may write and post that
1:13:18
vsync
pjb: naturally, more curious if there is such a thing intended generically, or a convention
1:13:45
pjb
vsync: notably, there you assume a CLOS class. But a protocol can be implemented with different kinds of objects. (structures, vectors, database backends, etc).
1:16:11
vsync
thought I ran into something about protocols some time ago that thought the way I thought about them... and certainly kicked it around here before
1:23:33
Josh_2
phoe was talking about it a few weeks back, I'm will ask him when it is a reasonable time
1:29:15
Josh_2
although I'm pretty sure he mentioned something about having to actually write the sql statements and not using a dsl
1:45:22
aeth
Someone should write some multithreaded CL benchmarks so we can compare CPUs and implementations. (Maybe those already exist?)
1:48:52
oni-on-ion
there always seems to be something about benchmarks they are either not specific enough or too specific
2:31:03
vsync
I'm trying to (re-)grok the rationale for having both a protocol class and a predicate
2:53:36
stacksmith
vsync: keep in mind that generic functions do not require classes... So you can define a 'protocol' as a set of generic functions that do different things depending on type, class, or a check for some parameter being equal to something else...
3:00:57
stacksmith
I find CLIM somewhat complicated. There is probably a good reason for things to be complicated, but I always curse and look for something less complicated before I get to understanding why.
6:03:54
beach
vsync: "filter" is really bad (for a different reason), because it doesn't tell whether it blocks the objects being filtered, or whether those are the objects that are retained.
6:04:33
beach
vsync: So how can you tell whether the argument is a value or a predicate, especially since predicates are values too?
6:11:23
no-defun-allowed
If they're rewriting something like remove/remove-if, I would expect it's an abstraction for a sequence containing elements of some specific type.
6:30:08
no-defun-allowed
My expectation is that they won't have any values that would look like predicates (so, not symbols or functions).
6:38:17
jackdaniel
CLIM specification is complicated because it describes at least three things: window manager abstraction, barebones I/O toolkit and CLIM itself
6:45:54
lukego
I'm coming to the pretty-printer late in life. I have a really newbie question. How come this errors in SBCL? (format nil "~<x~_y~>"). I've looked in the debugging and I see that ~_ is not allowed inside ~<~> but I don't get why not? I thought this would straightforwardly mean "put a newline between "x" and "y" if we don't have space on the line for both."
6:51:44
lukego
Maybe I am confused and need to read the Waters paper on XP again from the top. I'm hoping that it's only minor confusion.
6:52:59
lukego
beach: right but I want a conditional newline only if output is pushing close to the right margin, which is why I'm trying to use ~_ in place of ~%
6:53:29
lukego
and I'm expecting that ~<...~> will keep everything left-aligned in case the newline is needed.
6:53:58
lukego
Maybe I should just assume "deep" confusion and read the docs again from the start :).
6:54:21
beach
Yeah. I personally find the description of the pretty printer quite hard to understand.
6:55:00
lukego
I thought it made sense when I read it but I haven't actually been able to write working code based on my "understanding" yet so I may be deluding myself :)
7:02:30
lukego
dialectic: The three best resources I have on the pretty printer are 1989 documentation by Richard Waters (https://dspace.mit.edu/bitstream/handle/1721.1/6503/AIM-1102.pdf), a paper by Waters on printing Lisp with Pascal syntax (https://3e8.org/pub/scheme/doc/lisp-pointers/v5i2/p27-waters.pdf), and Peter Norvig's pretty-printer-driven transpiler from CL to Dylan (https://github.com/dylan-lang/lisp-to-dylan).
7:08:01
dialectic
While I have people's attention, does anyone have any resources for fast and space efficient multimethod dispatching? I've got the following two papers queued up already:
7:08:39
dialectic
https://hal.inria.fr/inria-00073721/document (compressed tables) and http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.45.7589&rep=rep1&type=pdf (automata)
7:09:07
dialectic
But I also was interested in implementation details for Lisp and SBCL specifically.
7:10:23
shka__
AFAIK there was even implementation of the said algorithm in the sbcl as a proof of concept
7:10:41
lukego
Edi to the rescue! "It is important that the closing "~:>" directive contains the colon as shown because otherwise this means something completely different (justification) which doesn't mix with pretty-printing." (p261)
7:10:47
dialectic
I should compile a comparison of all the different multimethod dispatch implementations in the wild.
7:11:32
lukego
So it could be that I have an accurate mental model of the pretty-printer but am just a n00b with the format-string directives and maybe should stick with long form (pprint-newline) etc first.
7:12:25
shka__
I have been programing in lisp for years and yet i still don't quite know how to do stuff with format
7:13:54
_death
lukego: long form is best.. otherwise it leads to having to manually decode the control string as in https://adeht.org/casts/new-project.html
7:14:52
dialectic
format is one of those things that when you first learn about you scorn but grows on you over time.
7:15:28
beach
dialectic: My paper takes into account the specific situation of Common Lisp where the classes can be redefined at run time.
7:15:29
dialectic
I like loop. I ended up preferring iterate, once I learned that. But loop is, still, good.
7:16:00
dialectic
Haha. One of these days I will come up with a good use for metaclasses. Actually, I probably never will.
7:19:27
_death
lukego: though I guess there could be a format-explain operator that automatically decodes it.. hmm
7:19:39
beach
shka__: Because they require memory accesses, which are an order of magnitude (or more) slower than register operations.
7:19:55
no-defun-allowed
Still reading, but the table could get big quickly with multiple-inheritance.
7:21:14
beach
shka__: Yes. My technique is based on a small number of comparisons with small constants, so it can be done by register operations.
7:21:15
_death
dialectic: I don't recall strong opinions towards this person from another.. in any case, it's the same Drew that wrote a bunch of Lisp papers, books, software
7:28:44
saturn2
i'm working on a web project that involves multiple similar but different sites, i used metaclasses to allow site objects to inherit things other than just slots and methods
7:29:14
fiddlerwoaroof
dialectic: if youre interested, I have an unoptimized implementation of multiple dispatch inJavascript, that I hope to eventually polish for use in "real" projects
7:31:14
fiddlerwoaroof
I've always foubd Clojure's multimethods disappointing: they're more like filtered dispatch than what CLOS has
7:35:08
beach
In fact, drmeister seems to be attempting the use of my technique for C++, instead of the usual, vtable-based technique used by most C++ compilers.
7:36:25
beach
shka__: Sure, I know many people get really excited about C++. I personally don't, but hey.
7:37:21
ggole
vtables are very much an implementation detail, but all the compilers do it that way afaik
7:37:30
shka__
beach: nah, now i am wondering what's going on, you have opened my eyes for some things that should have been obvious to me
7:38:31
beach
I am wondering about C++, because the main difficulty in designing my technique was to deal with obsolete instances, but C++ doesn't have that problem, so I am surprised nobody has come up with a technique based on inline caches the way mine is.
7:38:40
dialectic
beach: I haven't read this paper but are you saying that a generic function using your implementation should be faster than a table of function pointers?
7:39:21
ggole
It's possible to defunctionalise, and some C++ compilers are starting to do that (they call it devirtualisation)
7:40:42
beach
dialectic: C++ can probably be faster when the index of the table entry is known at compile time, but I am interested in dynamic languages like Common Lisp.
7:41:07
lukego
beach: My hot take on fast dispatching - which I realize nobody solicited :-) - is that the big win would be to make it play nice with the CPU branch predictor so that method bodies can be executed speculatively without waiting for loads. Seems like your approach should work really well in that sense based on a quick skim.
7:42:18
ggole
lukego: you want to change the table into a decision tree that branches directly to concrete implementations?
7:43:23
lukego
LuaJIT basically transforms all the data-dependencies into control-dependencies and then outsources the problem to Intel's billions of dollars of work on branch prediction.
7:43:24
ggole
There are a number of whole program compilers (for static languages, mostly) that work that way.