freenode/#lisp - IRC Chatlog
Search
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.
17:48:20
asarch
Yeah, since this concept actually doesn't exist in other language, it would take you more more time to do simply things
17:48:21
_death
in the past a limited form of "closures" was supported ("downward funargs").. but nowadays there's usually no need to distinguish function from closure (yes, there are exceptions when talking about performance, serialization, etc.)
17:53:20
jmercouris
makomo: It's been around a year of work, so not too long, but also not a trivial investment :D
17:54:02
makomo
jmercouris: i've seen it a few weeks ago too but forgot you were the author. it was influenced by emacs i see, which is very neat
17:54:14
makomo
i was thinking of a general framework for building emacs-like applications from time to time
17:54:23
jmercouris
makomo: Yeah, I try not to bring all the baggage of emacs though, but trying to keep it close enough
17:54:31
phoe
it separates the actual computation from the branching, which seems cleaner and more beautiful to me.
17:54:52
makomo
i.e. the standard "you have a minibuffer, you can run commands, you have keybinds and the lisp image of the process at your hands!"
17:55:27
dlowe
phoe: what about when you want to do the computation only on one branch, and you don't really want to nest conditions
17:57:34
dlowe
phoe: a classic example is (cond ((string= input "") ... no input ...) ((null (setf num (parse-integer input :junk-allowed t))) ... bad input ..) (t use num for stuff)
17:58:40
jmercouris
It can be ported to use just about any GUI framework as there is an API between the core and GUI that is extremely simple
17:58:46
phoe
dlowe: can you pastebin this for me? I think I need to read it formatted to understand it
17:58:51
jmercouris
the GTK port took me just 2 weeks, and most of that time was because I don't know GTK
18:13:09
borei
i have question about memory management in lisp. If for example my function is returning array what would be proper solution for this task - request array in the calling function and supply it as one of the argument and then fill with data, or just create array in the called function and then return it ?
18:13:38
Xach
borei: good question! both approaches are ok. in some situations it is better to do one, some the other.
18:14:10
Xach
borei: If your system has to be more strict about creating new things and using memory, passing arrays in to be populated can provide more control.
18:15:37
borei
but, speaking about second option, will that array be cleaned up by GC after called function completed ?
18:16:00
phoe
STATIC-VECTORS are a case where you'd want to pass an array to a function instead of creating a new one.
18:16:19
osune
I'm sorry but to ask such a simple question but I cannot comprehend at the moment the use case for FIND-IF. Or how it differs from FIND. Can somebody please state the obvious for me?
18:17:04
phoe
osune: FIND searches for an object that is EQL to something. FIND-IF searches for an object that satisfies a predicate function.
18:19:19
Xach
osune: it is true that sometimes functionality overlaps, and you could write a :test that would do what find-if does, but it would be pretty convoluted
18:21:00
_death
FIND is similar to (find-if (lambda (hay) (funcall test hay needle)) ...), disregarding certain details
18:21:44
osune
So i would have to 'workaround' with a lambda (x, y) (oddp x) or equivalent to use FIND. Thanks I wasn't able to grasp that at the moment and I started to get annoyed.
18:22:29
phoe
The moment I mention a thing to answer a basic question and other people go "that's advanced stuff, disregard it", I don't think I'm a newbie anymore.
18:26:45
Xach
phoe: I think sometimes when trying to help it can be hard to separate the "applicable knowledge" from the "necessary knowledge" for a situation
18:44:44
Shinmera
I was just reminded that I started writing a plaster.el . I guess I'll take that as a small project between exam studying.
19:45:29
dlowe
iolib is a full event multiplexer for managing lots of io operations and timed events
19:58:10
phoe
d4ryus: (over)simplifying things a real lot: usocket is portable, iolib is performant.
20:00:30
jasom
though note that the overlapped-io driver on windows is under-exercised (it works as far as anyone knows, but it hasn't been used as heavily as the epoll driver, so there may be some latent issues)
20:01:18
jasom
though that information is like 2 years old; pillton might know if it's being used more these days
20:02:02
jasom
ACTION remembers considering writing something like basic-binary-ipc but then thinking "that's a lot of boring, thankless, slog-work."
20:02:56
Shinmera
Speaking of things like that, I've been considering writing a github API client, but just the thought of dealing with oauth2 is making me cringe.
20:03:20
Shinmera
Will probably just bash my head through it eventually anyway though, if my past record is anything to go by.
20:04:26
Shinmera
If I wanted to be fully future proof I'd probably have to implement the v4 though, which uses GraphQL.
20:04:42
Xach
Shinmera: so i have one called "githappy" and you can plug in a token from the dev site to get full rate querying without going through oauth2
20:04:44
jmercouris
It was reccomended to me to use https://github.com/flathub to distribute nEXT, any feedback on this?
20:04:44
Shinmera
Looking at that spec made my eyes glaze over though, so that probably won't happen
20:05:28
jmercouris
Shinmera: There's already a few emacs github apis clients, why do you want to write one?
20:08:47
Shinmera
Xach: The purist in me is hoping I'll write yak-shave a GraphQL library and then use V4, but we'll see.
20:09:20
d4ryus
I have been using usocket, but iam missing stuff like checking how many bytes i can read from a socket without blocking.
20:13:02
d4ryus
once i do a read-line, or read-sequence n and the other end sends less bytes then i expect, my client hangs
20:14:26
Shinmera
Whatever for? Having a socket reader thread and a queue for messages is not a big deal.
20:15:40
Shinmera
And reading char by char is atrocious for performance, especially if you do the no-hang variant.
20:16:58
Shinmera
Using a thread and checking for input before reading a full message works perfectly fine.
20:17:52
Xach
d4ryus: I'm not sure what is portable, but sb-bsd-sockets:socket-receive I think will do the trick.
20:19:00
dlowe
I have some code floating around using iolib that opens a non-blocking socket, reads into an expanding buffer on input, and runs a callback function when a full line is read.
20:19:49
d4ryus
Shinmera: yes thats my current solution. Iam creating a thread for each connection, those get terminated in case they hang on read-sequence
20:22:17
Xach
I've often thought about a portability layer that does not try to pretend sockets are streams, and just offers read-octets, write-octets and a few other things.
20:24:58
Xach
I've had that happen with cl-ppcre! It grew special processor options for register-groups-bind after I learned how to use it.
20:28:34
Shinmera
d4ryus: Every other line is a reader conditional. I think that's pretty dependent.
20:29:21
Shinmera
I actually wonder why it was done this way rather than having each function defined in the platform specific file.
20:38:20
logicmoo
hrrm I noticed most all impls dont have private symbols in COMMON-LISP though most all describe the lambda list arguments that might have appeared in COMMON-LISP package as comming from their respective impl packages symbol examples are TEST,TEST-NOT,BODY etc
20:41:12
Shinmera
Uh, typically there's no reason to put symbols in there other than those that are exported to begin with
20:41:38
logicmoo
(some dont scrub them out they are litternally where they belongs and then later exported into CL)
20:45:24
logicmoo
in my impl (i followed ABCLs method here) i ended up with CL::TEST as a non exported symbol and was wondering how wierd it was to have several non export symbols in COMMON-LISP
20:47:49
specbot
The COMMON-LISP Package: http://www.lispworks.com/reference/HyperSpec/Body/11_aba.htm
20:49:23
Shinmera
You shouldn't (in-package :cl) anyway, so there's no reason other symbols might end up in there anyway.
20:51:45
phoe
in this case, interning symbols in CL package is undefined behaviour, BUT you're in a good place to define it
20:52:24
Shinmera
logicmoo: I'd just define the functions in your implementation package and then (export (import foo :cl) :cl). Maybe even make a macro that does that automatically.
20:52:27
logicmoo
mainly my concern was code that for whatever reason my call (find-symbol "..." :CL)
20:53:55
d4ryus
to clarify: sb-bsd-sockets:socket-receive with :dontwait t only reads all available bytes without blocking. Which means one could use usocket:wait-for-input to check which sockets have input available and then read from those all available bytes without blocking. This can be used to read from multiple sockets from a single thread.
21:11:19
Xach
I would make a defpackage with all 976 symbols exported, and then only reference them as cl:whatever thereafter.
21:23:21
borei
does lisp generate generic function for macroses ? in other words can i create 2 macroses with the same name but different signature ?
21:24:15
dlowe
borei: it will be the same macro but you will have to decide its behavior depending on its arguments.
21:24:23
cgay
sbcl CREDITS hasn't been updated for 5 years, so supplement it with the github commit history I think.
21:35:14
aeth
Don't forget that macros use a more advanced lambda list than functions. (defmacro foo (((&key bar) &key foo) &body body) `'(,foo ,bar ,@body)) (foo ((:bar 0) :foo 42) 1)
21:36:24
aeth
(&optional and &rest can be used instead of &key in that example, if you also change the way the macro's called)
21:37:08
aeth
The best part about this is that if you can do it entirely through the lambda-list, Emacs+SLIME will know the full API and tell you in the mini-buffer.
22:10:30
Shinmera
Anyway, point is, if you want to draw with GL you need a GL context and a GL window from the OS.
22:10:59
Shinmera
You could potentially do stuff like creating an offscreen context, rendering to that, extracting the texture, and then drawing that onto a native surface or whatever
22:12:16
aeth
Generally, people use SDL via cl-sdl2 to get the GL context and GL window and handle input. This is extreme overkill because you're bundling a large C library with tons of platform support you'll never use and tons of features you'll never use, via a large wrapper with additional features you won't use, just to get OpenGL up.
22:12:41
aeth
But I do this because doing things the right way would probably be harder. Doing things the lazy way probably makes distribution harder, though.
22:14:17
aeth
Fortunately, I only need to support X and Windows because Apple decided to not update OpenGL in the last 6.5 years or so.
22:18:20
aeth
I don't have the resources to maintain two renderers, a fast one for modern OpenGL and a slow one for OS X.
22:18:50
aeth
I also don't have the resources to overpay for hardware and get a Mac Mini just to test on OS X.
22:21:58
aeth
Shinmera: I currently use 3.3 and I am bumping up the API as I need the features, but I am not supporting OS X with my engine because I'm not going to limit my features at 4.1.
22:24:09
aeth
Anyone will be free to add #+darwin and #-darwin via patches to my engine if they want to. I just don't have the resources to do so myself.
22:25:42
aeth
It wouldn't just be the renderer, though, e.g. Windows and standard Unix configuration/local-data directories (e.g. ~/.config/ and ~/.local/share/) are supported for "free" through UIOP
22:49:21
aeth
For games, there's the Steam HW survey. Unfortunately, the Steam HW Survey is no longer accurate due to the massive surge of accounts from China for PUBG. It's unlikely that those accounts are going to buy most games, especially ones without Chinese localizations.
22:49:56
aeth
e.g. right now Linux is at 0.26%, way down from last year, but in the US, it's closer to 2.5% or so iirc.
22:50:50
Shinmera
It lists most cards used, but you'd have to crunch the numbers manually and that's a pita
22:51:50
aeth
And Intel's versions differ depending on platform because they have separate driver teams for Windows and Linux.
22:52:23
aeth
jmercouris: Android runs GL, iOS runs GL. (Technically the embedded version.) Only iOS and macOS run Metal. Mobile lock-in is the reason.
22:52:53
aeth
They'll take worse games on Macbooks to provide more exclusive games to iOS, where they get a cut on every sale.
22:53:49
aeth
How much does Apple make on games on macOS? They don't get any from the ones sold through Steam.
22:54:15
jmercouris
I think a typical mac user will install from the app store before installing steam client + some games
22:54:28
aeth
jmercouris: I think most people who game on Apple hardware probably use Bootcamp to game through Windows because Windows has much better support for games.
23:04:41
rumbler31
aeth: there exists a no-lib-necessary way to get an opengl i just need to find it
23:05:40
aeth
rumbler31: You essentially need to CFFI directly to X (or perhaps a clx-style approach would work), WinAPI, macOS's API, etc.
23:06:21
aeth
And, yeah, then if you solve sound, too, you have a 0-library approach, even though you do have to FFI to the OS and to OpenGL.
23:07:34
aeth
Shinmera: Is the sound library non-consing? The main reason (other than no libraries) that I'd want to replace cl-sdl2 is because it is the only thing in my game loop that conses, and a direct FFI approach could (hopefully) preallocate everything.
23:08:35
aeth
Not even stack allocating, except for a few matrices that would be a pain to deal with in non-allocating ways.
23:09:44
aeth
Ideally, the GC could be disabled during gameplay (can this be done in SBCL?) and only turned on outside of gameplay when consing could potentially happen. Although I'm not sure the GC would do much if all that's there are a bunch of long-lasting preallocated data structures that don't change.
23:10:36
Shinmera
Avoiding GC at all cost kinda throws a lot of what makes CL advantageous out of the window in my opinion
23:11:06
aeth
What makes CL adventageous is real macros and controlling when evaluation happens. The macros would be painful to write without GC, but the GC is happening outside of the game loop so it doesn't matter.
23:12:02
aeth
I have two styles: inside game loop and outside game loop. Only the former cares about avoiding consing.
23:12:26
aeth
I should probably update my CONTRIBUTING.md to explain this, although it's not like anyone contributes.
23:13:47
Shinmera
rumbler31: if I remember correctly doesn't work at all on OS X, has a broken, unmovable, borderless, fixed-size window on Windows.
23:14:43
Shinmera
jasom: if I remember correctly the GC shouldn't trigger unless there's pressure anyway, right?
23:39:10
aeth
I added an explanation of my no-consing style to my CONTRIBUTING.md: https://gitlab.com/zombie-raptor/zombie-raptor/blob/5e0f01a21cd1b3359925f726eddff9237f02d3ff/CONTRIBUTING.md#consing-heap-allocations
23:59:44
gendl
Hi, is there something which works similar to mapcan, but collects the results into a string instead of a list? (where the lambda function would return a string).
0:07:52
phoe
if you want longer lists, then go for a custom concatenator whom you feed a list of strings, which makes a fresh string of length (reduce #'+ strings :key #'length) and then copy-seqs each string into its respective place inside the result string.
0:18:38
borei
i'm implementing basic linear algebra library, was working on the matricies arithmetic operations - like '+', '-', multiplication by number, but COMMON-LISP package already has that operation defined as ordinary functions, does it mean that i can't use above operation normally like for example in C++ ? without package prefix like cl:+ ?