freenode/#lisp - IRC Chatlog
Search
10:32:22
White_Flame
acc = defaults NIL. (acc 1) = defaults 1. (acc 1 acc-p) = the acc-p boolean tells you if the caller actually included that parameter or not
10:32:40
White_Flame
the latter, because (factorial 3 1) is ambiguous as to whether the 1 was passed or defaulted
10:32:59
isBEKaml
White_Flame: yeah, I vaguely remembered seeing something like that in PG's ANSI CL book
10:33:34
White_Flame
also, there's #clschool for basic questions, a lot of responses will get advanced here
10:34:28
isBEKaml
thanks, I have worked around my failing memory with labels in that factorial function now
12:03:40
beach
To me, it is looking more and more like the authors of the standard had some very concrete implementation of the dynamic environment in mind, and that they tried to avoid such a concrete description in the standard, in favor of some more abstract language. The net result is a loss of precision, and also some contradicting terminology.
12:05:00
beach
I am currently trying to recover that concrete description. And then I will try to find a better way of turning it abstract so that no precision is lost. I am not sure that I will be able to do that though.
12:15:29
beach
It is interesting how one can think that one knows a language pretty well, but then when one tries to create an implementation of it, one discovers several holes in one's knowledge about it. And some holes in the specification of it as well.
12:37:15
ralt
a simple single-threaded event loop using only lisp and some small cffi wrappers is not too hard to do
13:46:41
Xach
i used it to do async dns and async http to have bounded response times for a web app.
13:52:17
ralt
Xach: yes, that's my point, a custom single threaded one is fairly straightforward once you have epoll
13:53:45
Xach
i cheated and didn't use the system resolver, just parsed resolv.conf and did direct networking myself. which does not work in all situations but did for me.
14:05:56
dlowe
I have no idea how this got called grovelling - maybe it's basically a form of giving up and begging other languages to do things
16:20:45
beach
Here is another question: Suppose we have a dynamic environment with entries C1 B C2 U, where C1 and C2 are CATCH entries with the same tag (say C), B is a BLOCK entry and U is an UNWIND-PROTECT entry. C1 is the oldest and U is the most recent. Now we do a RETURN-FROM B. So C2 is "abandoned". Then we run the cleanup forms in U. Suppose that U does a (THROW C). Is this operation invalid because C2 has been "abandoned", or is C1
16:25:34
beach
(catch 'c (block b (catch 'c (unwind-protect (return-from b) (throw 'c (values)))))) or something like that.
16:27:26
Bike
the clhs page for throw says it goes to "the most recent outstanding catch". I think interpreting "outstanding" to mean "not abandoned" is reasonable, and there's nothing to force the abandonment of C1, which is not an intervening exit point
16:28:12
Bike
also "the cleanup clauses of an unwind-protect see the same dynamic bindings of variables and catch tags as were visible when the unwind-protect was entered" in 5.2.
16:28:34
Bike
...well, i guess that kind of contradicts the intervening points invalidated thing, doesn't it
16:29:10
beach
I am wondering whether this is the exact example shown in the THROW dictionary entry.
16:30:51
Bike
No in that case the initial throw is to the same catch that the second throw ends up in - invalidation isn't relevant. i think.
16:34:08
Bike
i still don't really get the point of the "intervening exit points are invalidated" thing. the committee issue makes it seem like the point was to make it easier for implementations but that doesn't seem to actually be true
16:48:39
beach
Bike: I think that it will be harder for some implementations with their chosen strategy. But then, they let the implementation choose by making it undefined behavior.
17:11:25
proto
I can't figure out what makes functional programming better or even worth to use, rather than imperative programming. Functional programming restricts and establishes some guarantees, but this could easily be established with imperative programming languages as well.
17:13:05
dlowe
it's functional in that functions are first class objects, but it has iteration and global variables and stuff
17:16:22
edgar-rft
because in Common Lisp you can *combine* imperative, functional, OOP. whatever style in *one* program
17:17:20
dlowe
You can, but the fact that you might screw it up means that your cognitive load is not reduced so much
17:17:29
shka_
but oh my god, writing large systems this way is impractical and i don't think i know anyone that does that
17:19:37
shka_
proto: try passing void* as explicit closure every time and you will quickly loose your mind
17:20:23
shka_
also, you can't just (lambda (x) (+ x y)), you will have to define function elsewhere, and then the state, and then initialize the state…
17:22:51
proto
shka_: give me the simplest example of a closure, and why they are far superior to a simple struct with methods.
17:26:27
proto
No. I don't that at all. I am just applying doubt to obtain certainty and understanding.
20:23:34
jmercouris
the advantage of a closure? honestly, I find it really rarely comes up in my workflows
20:23:51
jmercouris
that could just be a product of how I think though, maybe others find themselves using them much more frequently
20:25:04
jmercouris
there are those contrived usages that I see occassionally to illustrate how clever they are, but I don't find them applicable oft
20:38:29
Xach
cl-ppcre uses closures in a nice way to compile its regular expression matchers without using cl:compile.
20:44:00
jackdaniel
jmercouris: (defun start () (let ((app (make-app))) (bt:make-thread (lambda () (loop (poke-a-bear app)))) (run-app app)) ; comes to mind
20:44:43
jmercouris
jackdaniel: yeah, but that isn't like a super clever usage of a closure or anything
20:45:09
jmercouris
I'm talking about people that would use it to made a function like "counter" or something that captures a value to know how many times it has been invoked
20:47:15
jmercouris
just to be clear, I'm making a joke here, I'm sure cl-ppcre makes a good usage of closures
20:47:38
jmercouris
we actually use them in Next quite a bit, specifically for candidate completion, we often build closures that capture some state and complete upon it in the minibuffer
20:47:58
jmercouris
to avoid continuosly polling whatever state we are completing against with every keypress
20:51:00
aeth
A closure is the only way to get true encapsulation in CL afaik... but you rarely need that.
20:52:00
jmercouris
I guess if all of your objects were encapsulated in closures or something, you could have true OO in CL
20:52:35
aeth
I tend to prefer to have an explicit state argument to a function passed in as a higher order function over making a closure. I can see why you'd want to do it the other way because it makes the API cleaner, but it also makes it, well, less transparent each step.
20:53:41
jmercouris
jackdaniel: https://en.wikipedia.org/wiki/Object-oriented_programming#Encapsulation
20:53:56
aeth
An OOP definition is basically "choose 4 of these 15 things from the list and turn it into your OOP definition"
20:53:56
jmercouris
"programming concept that binds together the data and functions that manipulate the data, and that keeps both safe from outside interference and misuse"
20:54:17
jmercouris
it's very clear that CL doesn't make this guarantee, like for example private in java, which does
20:54:32
aeth
You can encapsulate slots in CL in two ways... one, you can make the slot name a symbol like %foo and not export the symbol... if you trust your users
20:55:22
aeth
jmercouris: MOP isn't standard, and even if that's the case, you can probably override the MOP in your metaclass to protect them!
20:56:29
jackdaniel
I read it: so you can use functions to manipulate data without accessing it, not that you enforce lack of such access. that said I think that there was a very good post by Erik Naggum explaining why you are wrong with this "trueness"
20:56:29
aeth
(On the other hand, closure encapsulation might be safe from the debugger if (debug 3) isn't the current optimization level, because the private variables might be optimized away.)
20:57:19
jmercouris
jackdaniel: well, there is no official governing authority on what is OO and what is not, I'm sure there is quite some debate
20:57:38
aeth
I'd personally consider defclass encapsulation using a slot definition like (%foo :accessor foo :initform 42) to be an acceptable encapsulation... at least for the user. The MOP and a few other things make things too dynamic for the compiler or interpreter
20:57:39
jmercouris
it doesn't provide encapsulation because you can always violate the encapsulation
20:58:39
aeth
jmercouris: A definition that excludes Python, an extremely OOP language, is imo too strict. I think in Python you just make things private via names, like __foo__ or something
20:59:12
jackdaniel
also, it seems that the person writing this wiki entry indeed thinks that OO = C++
20:59:41
jmercouris
however the lack of multiple inheritance, and having to use protocols instead, a bit of a bummer
21:00:13
aeth
Java has things that violate its own OOP purism like having a separate 'int' type from 'Integer'
21:00:31
aeth
You also don't have to force everything to live with a class to use OOP heavily, as both Python and C++ show
21:00:57
aeth
jmercouris: Common Lisp has integer without harming performance, and is sometimes better than Java here
21:01:51
aeth
well, fixnum is a subclass of integer, and can be handled as a special case without really existing as an "object" instance except when you do things like (class-of 42)
21:02:23
jackdaniel
there it is: https://www.xach.com/naggum/articles/3243735416407529@naggum.no.html
21:03:31
aeth
jmercouris: Method calling in CL is expensive because CL is (mostly) dynamically typed, so it can't optimize the call at compilation time, except perhaps if you add type declarations (although that's rare enough that I doubt that's optimized in most cases in most implementations)
21:03:36
jackdaniel
description on the wiki page of OO reminds me people confusing weak and dynamic typing
21:04:18
jmercouris
you could edit it if you really disagree, however you'll have to provide literature...
21:06:00
jackdaniel
I could but I won't ;) all I'm saying is that I'd be careful with definite claims about "true" <whatever>
21:09:11
aeth
An object oriented programming language is only object oriented if and only if it has a metaobject protocol[1], thus making Common Lisp and Perl rare examples of object oriented programming languages. [1] source: my blog
21:11:35
jackdaniel
I'm cure I've said (paraphrasing): you are wrong about that encapsulation defines trueness
21:12:46
aeth
Anyway, encapsulation depends on the language local conventions if there isn't a "private" keyword or similar. In Python, it is good enough to do __foo for a private member. In CL, a private slot name is just %foo if %foo is not exported in the package. Pretty simple and straightforward.
21:12:56
aeth
I don't think that that is particularly controversial, although a C++ or Java programmer might dispute it
21:13:25
jackdaniel
aeth: one could even claim, that slot names are implementation details and using slot-value is in bad taste
21:14:04
aeth
jackdaniel: I do, but I make that claim by making all of my slot names %foo style. Anything that isn't is an old-style defclass of mine and essentially a bug.
21:14:51
jackdaniel
sure, %foo makes sense. also adding accessors with name %whatever to bypass "official" protocols with all auxiliary methods
21:16:12
aeth
jackdaniel: I sometimes do things like (%foo :accessor %foo :reader foo :initform 42) where %foo is the "internal" reader/writer (easier to have two readers than having a writer with a different name than the reader)