freenode/#lisp - IRC Chatlog
Search
5:48:18
madpengu
The idea that you reason about differently in a higher abstraction is given. C is a different abstraction than ASM (though, I always C as just a glorified crss-platform ASM) so there is ought to be a difference in how you think about a problem.
5:48:39
madpengu
Though when you talk lisp, you're not even talking about the same instructions most of the time.
5:51:05
jasom
madpengu: assembly language can support multiple return values; arithmetic operations set cpu flags that are not accessible from C; most assemblies have at least one way of dealing with signed arithmetic overflows ...
5:51:43
madpengu
jasom: Just because you can't reason in C the way you do in ASM doesn't mean that your reason in C isn't mostly directly translated to ASM.
5:52:38
jasom
madpengu: I could show you dozens of examples of C code turning into something very different from what your reasoning would expect
5:54:57
madpengu
But the abstraction between Lisp and CPU is orders of magnitude thicker than C and many C-like languages.
5:55:01
jasom
madpengu: consider a 32-bit machine: int wordFromByte(uint8_t x[4]) { return x[0] <<24 | x[1] << 16 | x[2]<< 8 | x[3]; }
5:56:09
aeth
madpengu: Common Lisp's iterations are, for the most part, ultimately just gotos contained within a tagbody.
5:56:14
jasom
madpengu: how is that a clean mapping to assembly, where it would have a defined result for the straightforward translation to assembly (and not only defined, but the same on all architectures)
5:56:35
borei
seem like setf method is more complecated then i thought initially, and now seems like i missed track to get understanding how does it work
5:56:54
madpengu
jasom: But isn't that undefined by standard? If you don't speak proper C, don't expect proper ASM ;)
5:57:39
borei
i have two classes generic-matrix and matrix-r, first class is parent for the second one
5:57:40
madpengu
Maybe at this point I can't see past the lisp abstraction, but so far, it feels thick, maybe it has to do with it being a managed env.
5:57:50
aeth
An optimized pure FP language or a JIT scripting language has a lot more magic abstraction going on
5:58:19
jmercouris
+1 on what jasom says, C doesn't compile in the way you IMAGINE it would, modern day optimizations are intense
5:59:10
jasom
on several compilers array-referenced loops are faster than pointer-referenced loops because the optimizaer has an easier time of turning it into a decrementer loop
5:59:19
madpengu
jmercouris: Optimizations still do what you expect it to do, maybe in a more efficient way, with lisp, I have no freaking idea what CPU is going to do. Maybe it is just me, maybe it is lisp.
5:59:41
borei
now i need to do setf for elements (not spamming here) - https://pastebin.com/qE26sKMR
5:59:46
rme
It doesn't sound to me like you know CL well enough to make such a judgement or to develop such intuitions.
6:00:28
madpengu
jmercouris: What do you mean? if optimizations doesn't do what I expect them to do, then the compiler is broken.
6:00:34
aeth
madpengu: I'm more confident in what CL is going to do than what an optimized AOT or JIT compiler is going to do because of how sophisticated some of the optimizations in some languages can get.
6:00:47
jmercouris
madpengu: I mean that they are so complex that you will have trouble understanding them completely and all of their behavior
6:01:17
aeth
madpengu: It's actually kind of a bad thing that CLs aren't automagically optimizing everything. Naive CL is going to be slow, and fast CL is probably going to look a lot like C, unless you have a lot of custom macros to abstract.
6:02:05
jmercouris
madpengu: If you claim to be the individual that understands all C compiler optimizations, then you are the first I have ever heard of
6:02:53
jmercouris
Anyways, before making an argument we have to establish some axioms, I don't agree that it is an advantage to understand the underlying assembly
6:03:18
aeth
madpengu: Except C is going to have optimizations that do crazy things and CL that looks a lot like C is going to run like C without all of those crazy optimizations turned on
6:03:39
madpengu
jmercouris: No one claimed that. In fact, if you require an understanding of the mechanics of an abstraction, it is a very bad abstraction.
6:03:48
aeth
SBCL is the fastest CL implementation and I haven't had a WTF moment yet in reading the disassembly.
6:03:56
madpengu
jmercouris: But none the less, not being able to reason about the mechanics of an abstraction also makes it hard to grok.
6:04:11
jasom
madpengu: I am, in fact, assuming I know more about C than you; it's possible I'm wrong...
6:05:16
madpengu
I also don't like how every conversation about lisp or most everything about here is a schlong weaving and measuring contest. lisp is great, but it is not the end of it all, people. Chill.
6:05:44
jmercouris
jasom: it doesn't persist sessions in between open/close, but it's definitely "usable" whatever that means :D
6:06:25
jasom
madpengu: it's not the end of it all. However, that doesn't mean that I agree that the mapping from C to assembly is easy to understand...
6:07:15
borei
btw, i got some first small result with my LISP adventure - implemented multithreaded GLFW-based application (well it's hard to call applcation, but seems like im right direction :-) - sounds strange, some basic lisp aspects still a bit fuzzy.
6:09:16
jasom
madpengu: To a certain regard it is a binary question; IMO any significant code in C is non-trivial to reason about the mapping to assembly
6:09:23
aeth
madpengu: One thing I've noticed about IRC is that if you say something that someone thinks is incorrect, people will line up to try to correct that statement.
6:11:07
jmercouris
madpengu: Don't be mad, it's not worth it to be angry. Getting angry is like drinking posion to punish the person you are having a disagreement with
6:12:02
jasom
There is a subset of C for which the mapping to assembly is quite clear, but the same is true of any lisp descended from cmucl
6:15:08
borei
if i have array of double-float, and im trying to assign integer value to one of the item - im getting error wrong type
11:50:39
makomo
does anyone know why (let ((*print-circle* t)) ...) doesn't work but setf-ing it before executing the body of the let does?
11:51:31
beach
makomo: Perhaps you are returning a circular structure and you expect it to be printed as if *print-circle* is true?
12:00:19
Shinmera
beach: It seems like the kinds of people and discussions going on in this channel come in waves and tides, which is why I sometimes give up on it and leave for some time.
12:02:23
Shinmera
I don't ignore on principle because it's not context sensitive and won't stop people from responding.
12:04:51
beach
I have only used it once, and it was when someone explicitly asked to be ignored so that he or she could continue discussing commercial software in freenode without my complaining about it.
12:08:28
beach
Then we could ignore all topics such as "I wish the Common Lisp HyperSpec were different."
12:09:03
Shinmera
Or "common lisp is not popular because", "if people did X then...", "cl has to be popular", etc.
12:11:16
beach
What do you mean? Its name is #lisp, I ought to be able to talk about ANY Lisp dialect here.
12:12:53
Shinmera
I was trying to make a joke about these being the only discussions here, but yeah, enough grumpiness.
12:16:08
jackdaniel
one could wonder, if some (stupid) question is repeated over and over again by independent people could it mean, maybe it is not that stupid but rather there is some environmental misclue
12:19:47
dim
IMO it's mainly people who learn better by talking and don't bother reading docs and trying things out, and come directly here to chat about it, and hopefully build a reasonable mental model of lisp before they try things out
12:20:27
dim
so of course there's a lot of repetition, tutoring new beginners again and again... an eternal september of sorts?
12:21:50
Xach
I do hate "This is dumb and it shouldn't be this way" and "I'm just trying to finish a class, give me the answers"
12:21:51
dim
exactly, me neither, just not every day... (and I don't have proper answers that often anyway) ;-)
12:23:07
dim
some 15 years ago I would complete a friend's lisp assignements (he was sharing them on IRC) using librep (the kind-of lisp implementation for sawmill, then sawfish), it was fun times
12:25:41
makomo
i, for one, appreciate that you guys answer (nooby) questions over and over again because even though i have no problem reading formal references/docs, sometimes an actual dialogue with another human being helps in clarifying stuff
12:26:31
logicmoo
for myself the very advanced concepts are easy.. but very basic ones are not example of a basic one i have right now i do not think i found covered in books.. "would it be better to define symbols say in My-IMPL-SYS:*COMMANDLINE-ARGS* and have them reexported to EXT"
12:27:06
logicmoo
(i mean to say it might not be that simple of a question on but i think it is simple that if i have to ask.. then i really dont need to know)
12:30:32
dim
also CL provides so many ways to do things, sometimes it's hard to guess if you're going to be stuck because of a simple choice
12:30:37
makomo
people should be taught early to recognize such situations and how to deal with them
12:31:42
makomo
dim: i agree, that's usually what should be done. just go with it, don't think, do it.
12:34:21
logicmoo
ok1.. me makes a package called "SYSEXT" and nicknames it SYSTEM and EXTENSIONS .. while i am compiling all of ECL's ABCL's, and CLISP, and GCL systems to get a big ball of non interpreted functions
12:35:55
logicmoo
afterwards I will probly just put it all into system, then see what most of them vote belongs in EXTENSIONS
12:38:03
logicmoo
so far each lisp, supplies a different 70% (from the others) that ends up being ideal in my system
12:42:28
logicmoo
the hardest part in all of this is allowing myself is when i have to give up one or more of an individual well thought patterns by an impl
12:59:48
otwieracz
antoszka: ningle handles PATHNAME correctly. So when your route returns PATHNAME, then instead of somehow-sending-it it streams contents of the destination.
15:01:08
Bike
phoe: #' is basically defined to return `(function ,(read)), so yeah, whitespace is no prob.
15:05:25
crsc
phoe: I use vi more than 20 years now and it's hard to learn emacs. But I'll give it a try.
15:06:17
phoe
you might want to check https://spacemacs.org out since it's based on emacs's evil mode.
15:07:07
phoe
portacle has an upside of being self-contained, but if you have 20 years of vim experience, then I'm pretty sure you can hack your own environment up pretty quickly. (:
15:07:59
phoe
also, #lisp is a good place for Lisp questions but #clnoobs has been created specifically for CL learners.
15:16:45
Xach
More like it's close enough to emacs that the little differences are really distracting and offputting.
15:23:48
warweasle
I wanted a mixture of blender and emacs. It was too large a project for one person.
15:34:45
beach
makomo: #clasp is about the Clasp implementation of Common Lisp and #sbcl about SBCL.
15:35:04
makomo
beach: i've been in #clasp since i've been in #lisp. in fact, it's what drove me to start getting into CL more :-)
15:35:39
makomo
since i come from C++ and got intrigued by lisp, the combination seemed awesome to me
15:36:51
makomo
same with C++/Common Lisp, although they're pretty different languages so the comparison doesn't transfer that well
15:39:25
makomo
however, spacemacs comes with full vim keybinds set up for you (which is why i started using it myself) ;-)
15:50:34
sjl
flip214: no, but I haven't really been paying attention. I've been traveling a lot over the holidays.
15:50:36
flip214
I had a few email exchanges re bugs and features, but got no replies for ~.52 months.
15:51:07
flip214
I'm afraid that something bad happened... perhaps by drawing attention via the emails
15:55:42
flip214
the github contribution picture at https://github.com/l04m33 breaks off at the same time
15:56:58
sjl
It's possible they're just taking a break from computer work for a while. I've done it for a couple of months at a time in the past.
16:51:34
asarch
But I finally could understand the concept. From the point of view of JavaScript: "A closure is created when a function inside another function gets stored outside the outers function's scope while retaining references to a variable from the outer function".
16:52:50
asarch
So, if real life could apply closures, a closure would be like a photograph. Even when the people in the photograph have gone, you can "reference" to them by the picture
16:54:20
asarch
So, my next question is, why would you need closure? You could easy store the return value from a function in a variable
16:56:47
beach
asarch: When that form is evaluated, it returns a function of zero arguments, that, whenever called, returns a larger value.
16:57:30
beach
So the function/closure contains state in its environment, in this case, the value of the variable X.
17:01:12
beach
If you are not using SLIME, start with (defparameter *f* (let ((x 0)) (lambda () (incf x)))).
17:01:24
pjb
You can call the code, the code can process the data, but you cannot touch the data directly from outside.
17:03:21
Xach
Sorry. I need to migrate all that stuff, but it feels like it might be a lot of work :(
17:05:55
beach
asarch: *f* does not print anything, so you need to do something like (loop repeat 10 collect (funcall *f*))
17:08:37
pjb
(let ((x 0)) (lambda () (incf x))) is equivalent to (defclass anonymous ((x :initform 0 :accessor x))) (defmethod m ((o anonymous)) (incf (x o))) (make-instance 'anonymous)
17:09:28
pjb
How would (defparameter *f* (make-instance 'anonymous)) (dolist (i 10) (m *f*)) print anything?
17:16:13
pjb
or: (let (r) (dotimes (i 10 r) (push (funcall *f*) r))) #| --> (10 9 8 7 6 5 4 3 2 1) |#
17:31:26
beach
OK, let's say we have some example list like (defparameter *l* (loop for i from 0 below 10 collect i))
17:32:26
beach
We can use REMOVE-IF-NOT to keep only elements that correspond to a certain predicate. For instance, we can say (remove-if-not #'oddp *l*)
17:34:50
jmercouris
Hey everyone, I just released the alpha GTK port of nEXT, if you like my project, please upvote it: https://www.reddit.com/r/programming/comments/7p8nv0/next_browser_a_powerful_extensible_lisp_browser/
17:35:19
beach
asarch: But now we want to generalize this so that we want a function F that takes an integer N and a list L and that keeps all the elements of L that are greater than N.
17:35:49
beach
asarch: We can do it like this: (defun f (n l) (remove-if-not (lambda (x) (> x n)) l))
17:37:18
beach
asarch: Here, (lambda (x) (> x n)) is a closure, because it refers to the lexical variable n in a surrounding function.
17:40:10
beach
asarch: Here we use the closure to refer to an implicit parameter. The function that we pass to remove-if-not must take a single parameter, but we need two parameters, both the X that receives elements from the list and N which is what we passed to F. The solution is to create a closure with a single parameter X that refers to a closed-over variable N.
17:41:38
_death
furthermore you can create a predicate-building function.. (defun greater-than (n) (lambda (x) (> x n))) this makes it possible to write (remove-if-not (greater-than 3) list)
17:44:36
beach
asarch: As _death points out, with this style, you obtain a collection of very small, very general, functions that you can then compose arbitrarily.
17:46:13
beach
asarch: In a language without closures, you can't do this, because you would have to alter the signature (the number of parameters), and doing so would break the abstraction barriers, so the code is no longer modular.
17:46:47
pjb
You can do it trivially in object oriented programming languages, trivially, but with a lot of boilerplate.
17:47:24
dlowe
sure, iirc, closures in java 8 creates an anonymous class with the free variables as stored members.
17:47:36
pjb
But then, given the above equivalence, "language without closures" excludes OOP languages.