freenode/#lisp - IRC Chatlog
Search
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:+ ?
0:32:11
borei
seems like best approach would be introduction of alphanumerical functions names like - add, subtract, mult, divide etc
0:44:11
Xach
borei: "shadow" in the lisp sense means what happens when you use a package but don't want to use it all
1:02:02
jasom
Shinmera: all I know is that whatever heuristic sbcl uses for invoking the GC doesn't usually do what I want. I typically invoke the GC manually
1:18:57
aeth
borei: If you're writing a linear algebra library and you want generic arithemtic operators, you probably want to use specialization-store by pillton instead of writing your own macros. https://github.com/markcox80/specialization-store/
1:20:03
aeth
You *might* be able to use it to still call cl:+ for types that cl:+ supports, with most of the work done for you.
1:21:12
aeth
specialization-store basically lets you define functions that work in (roughly) the same way as the built-in CL functions that are generic over sequences or numbers. Runtime dispatch on unknown types, but more efficient code if the types are known.
1:24:14
aeth
(This only happens when inline, but if you want a middle ground for more complex functions that probably shouldn't be inline, you could define functions that are called by inline specializations.)
1:26:32
aeth
(And you'd probably want to wrap that function call in (the foo-type ...) if the return type is known)
1:28:54
aeth
(Actually, it'd be great if specialization-store had something like :inline-function-call that did this automatically.)
1:29:11
ebrasca
No applicable methods to generic function #<Standard-Generic-Function PARSE-NAMESTRING-USING-HOST 400000002539> (PARSE-NAMESTRING-USING-HOST) when called with (#<Mezzano.Fat32-File-System::Fat32-Host 400001E51469> ">Fonts>LICENSE" NIL).
1:31:43
Bike
parse-namestring-using-host is a generic function, and it doesn't have any methods that would fit the classes of those objects.
1:35:23
aeth
Bike: Is it possible to write hygienic macros in CL without any libraries? If not, is it possible to write hygienic macros in CL with introspect-environment? Or is there some vital information missing? https://github.com/Bike/introspect-environment
1:35:43
aeth
The main thing I know about hygienic macros is that they require knowledge of the environment.
1:36:21
Bike
not something i care about, but maybe see https://pdfs.semanticscholar.org/8b69/c81fff9a5ecebdd0a5839536eb7d716d8b5b.pdf
1:47:21
aeth
Here's why: I think I could actually produce faster CL code by generating CL code from CL code since cl-cl would be able to analyze the whole program and essentially automatically apply little optimization tricks.
1:58:09
asarch
"Today, I want to use CLISP instead of SBCL" <- Is there any way to start SLIME with a different Lisp?
2:03:46
sigjuice
asarch: the Run Lisp: prompt in the minibuffer should also have history, accessible by <up>/<down>
2:10:20
sigjuice
This is also super convenient for trying out a different version of an SBCL binary release. There is no need to "install" anything. C-u M-x slime ~/sbcl-1.4.3-x86-linux/run-sbcl.sh RET
2:41:44
sigjuice
Also leaves behind a *slime-events* buffer. C-h f slime-quit-lisp RET says "Quit lisp, kill the inferior process and associated buffers.".
3:43:52
ebrasca
jmercouris: Probably not used as primary os , but I can start mezzano in my PC bare metal.
4:55:16
aeth
Is it possible to use static-vectors (which appears to be terribly documented) to allocate a big chunk of memory and use a subset of it? This appears to be very possible in C: static-vector-pointer has an offset parameter, which is either in bits or bytes (again, terrible documentation... I'm guessing bytes?) so the byte size given in cffi:foreign-type-size definitely can work there.
4:57:53
aeth
(Although it looks like making an offset pointer appears to be a complicated, consing process)
5:02:38
aeth
So one possibility would be to patch it to make it work in general, but another possibility is to just work with offsets.
5:03:32
aeth
I think an issue with working with a range, though, is that the function could bounds check each aref, which could become expensive for a large range (e.g. 16)
5:08:15
aeth
At least in the SBCL I am on, not only does it have an INVALID-ARRAY-INDEX-ERROR for each index, it also doesn't appear to be smart enough to remove those checks automatically if I first do a manual length check
5:15:36
aeth
The function is 1253 bytes when it knows the length, so inlining is out of the question
5:22:49
aeth
that keeps the other elements of the safety, which declaring the whole function unsafe would not do
5:24:13
pillton
There are references in the book "Types and Programming Languages" by Pierce which discuss the subject of automatically removing array bound checks.
5:26:15
aeth
I guess if it's always a fixed size range only give the starting point of the range, and check that the (> (length foo) (+ start range-length))
5:39:24
aeth
because otherwise it would perform worse with global safety 0 because it forces some limited bounds checks that otherwise wouldn't be there
5:48:46
aeth
Otherwise, if the program is compiled with (safety 0) I will have accidentally introduced some safety to it
8:02:46
phoe
pillton: correct, it has a mechanism for that, you can use its functions inside macros.
8:31:19
beach
jdz: Sadly, many of the discussions here involve using Common Lisp to do unsafe things such as accessing memory directly.
8:40:52
beach
Well, since most people think Common Lisp is irrelevant as well, then one might as well use a language that is unsafe by design, rather than trying to twist an otherwise safe language into doing unsafe things.
8:51:09
p_l
beach: I'd argue that since our computational substrate doesn't provide some higher abstraction by itself, we should strive to give all the power we can while simultaneously making the easy problems trivial, hard problems easy, and insane problems doable, for the end user of the tool
8:56:14
jackdaniel
while direct memory access may be considered unsafe it is only a minor bug which may be avoided (that is a case for using language which manage memory for the programmer, I'm all for that and we have a lot of mainstream languages doing that too) - avoiding this class of problems doesn't make a language safe though
8:57:14
beach
So you are saying, Common Lisp is unsafe anyway, so we might as well go the extra mile to make it totally useless?
8:58:38
jackdaniel
what I'm saying is that trading "unsafe" language to Common Lisp is trading one "unsafe" language to another "unsafe" language, so it is not a very good argument to switch
9:00:20
jackdaniel
(for instance Java doesn't have direct memory access but many people seem to dislike it and software written in it still has bugs which lead to unsafe behavior, yet some of bloat could be mitigated with macro abstraction which it lacks)
9:01:48
p_l
beach: CL is "safer" in the default state. Essentially giving "sane defaults" while at the same time providing ways to expand *when needed*
9:02:01
otwieracz
Do you have any ideas for examples how to handle file upload properly with clack/ningle?
9:02:17
p_l
beach: someone nicely described "low-level language" as one where issues irrelevant to problem being solved are important :)
9:05:10
aeth
And I'd love not to have to use CFFI at all. If we add window, input, sound, and 3D graphics to the next version of the standard, I guess that'll get rid of a lot of reasons to use it.
9:08:42
jackdaniel
/another kind of safety improvement would be static typing which some could argue (me included) would be an overkill for CL/
9:09:45
aeth
Because CL has sequence-generic and number-generic things, declaring types for sequences/arrays and numbers makes a big difference.
9:10:10
aeth
I think the compiler can normally tell what type is expected by what functions are being used on it, although I could be wrong.