libera/#commonlisp - IRC Chatlog
Search
12:52:11
pkal
It usually does, I prefer that to remembering various "exit", "quit", ... commands for different programms.
13:41:46
doomduck
looking at sbcl not supporting mobile, is lispworks the only way if you want to say make an ios/android game?
14:28:23
philipp_
Hi everyone, I try to follow the cffi tutorial here: https://cffi.common-lisp.dev/manual/cffi-manual.html#Tutorial_002dGetting-a-URL ; however, when I call (curl-global-init 0), I only get: "The function COMMON-LISP-USER::CURL-GLOBAL-INIT is undefined." Any Idea why?
14:30:08
philipp_
Yes, that was it. Of course, in the tutorial they define the package ":cffi-user".
14:56:00
doomduck
jackdaniel: oh wow wasm would be amazing, I guess that'll be the first way to get "CL in the browser" right?
14:56:26
doomduck
tho I just make games, so I guess cl-sdl2 should in theory work with ECS on ios/android?
14:59:00
jackdaniel
there was a person who was first to run some other cl in browser (the one entirely written in c, not clisp though)
14:59:21
doomduck
hmm, this sounds better than I had thought it would ... idk why I had this notion that CL is "mainly linux and everything else sucks"
14:59:54
doomduck
are there any downsides/limitations in ecl compared to sbcl? I've only used sbcl so far --- I guess I should google a bunch about this :>
15:01:06
doomduck
I remember iOS having restrictions about "interpreted" languages and/or anything that would allow runtime script running/mods, tho that may be ancient history since people run javascript apps on ios hmm
15:02:07
jackdaniel
gf dispatch is slow (in comparison) - will be fixed soon; slow compilation (nothing we can address atm), no type inferencer (working on it), sbcl produces better code usually (partially implied by gf dispatch and type inference, but not only)
15:02:08
doomduck
being new to CL I'm still struggling to understand how there's this amazing ability to just connect to a running thingy and do things to it remotely and keep compiling code ...
15:02:52
jackdaniel
ecl has two compilers - to native binary via a c compiler and to its own bytecode vm
15:03:31
doomduck
maybe a stupid question, but since ecl compiles to C does it still include a compiler in a way that lets you hot-reload in the resulting binary?
15:04:00
jackdaniel
ecl can work without native compilation on ios - performance critical parts may ve precompiled beforehand (and should be if it is an app)
15:05:15
jackdaniel
but c compilwr is not part of ecl, so to compile to native you need the c compiler (or use bytecodes one)
15:05:59
jackdaniel
as I said, it produces slower code than sbcl; there is also no save-lisp-and-die
15:07:08
doomduck
haha, maybe one more question - being new in the CL universe with no ties to anything "from the past", is there any reason I should be looking at lispworks?
15:07:52
jackdaniel
sure, they provide excellent implementation with support, ide and good libraries
15:09:04
jackdaniel
well, things are either properly funded or are driven by unpaid labor; nothing wrong with love but money can buy stuff (like dood!)
15:11:42
doomduck
it's just so strange looking at all the webshit (I have some frontend background) where everyone and their mom makes a new shiny library ... now I come into CL land where there's multiple compilers, each doing their own thing, and even paid options ... I'm so so so confused, but in a good way
15:11:52
_death
the other day I wrote https://adeht.org/clog/ .. if there's interest I suppose both the model and UI can be fleshed out
15:48:10
jcowan
doomduck: In terms of multiple implementations, CL is peanuts. Scheme (another Lisp variety) has over 80, not counting historic implementations that only run on dead hardware (or its emulations)
19:16:35
doomduck
a question about CFFI, I'm trying to call this https://github.com/longlene/cl-raylib/blob/master/src/raylib.lisp#L2252 which wants a :pointer via CFFI, but uhm ... looking at the CFFI manual I'm not really sure how to construct a pointer to a number on the CL side?
21:34:07
doomduck
can I somehow access a constant defined in a package that doesn't export it? specifically this https://github.com/longlene/cl-raylib/blob/master/src/raylib.lisp#L1241 ... I guess I could just copy the number in this case if there's no way tho lol
21:37:28
doomduck
oh awesome thanks! they have a TODO on this whole section, so I assume it's probably something they want changed
21:41:11
phoe
basically, in Lisp, using the foo:bar syntax means "can I please use this symbol?" whereas using foo::bar means more or less "*reloads gun* I aren't asking this time"
21:41:44
phoe
at which point lisp is nice enough to give you the symbol, but yeah at this point it's just your responsibility to use it without breaking stuff
21:43:48
verisimilitude
Note, doomduck, that the :: syntax works even if the symbol be exported, so changing it if the symbol becomes exported isn't necessary.
22:07:33
kakuhen
no harm in always referencing a symbol SYM in a package PKG as PKG::SYM, but the reader will have no immediate answer on whether PKG::SYM is exported or not -- my argument is mostly for the reader's convenience
22:09:33
phoe
lisp is a language for nice people and nice people generally ask for access, hence using single colon is preferable
22:14:55
doomduck
phoe: I thought lisp was a language for people who don't ask for anything and just take what they want because they can literally patch anything in anything :D
22:31:52
aeth
Ime, nobody exports their classes. Maybe because they're afraid of someone doing (make-instance 'foo) when that's not the proper way to make it, but it also stops you from doing (check-type x foo)
22:32:21
aeth
This is essentially the only time I use :: the "right" way, outside of my own unit tests or when I'm doing something I probably shouldn't do (messing with the internals of something).
22:33:46
phoe
I kinda pointed this out a few times - if a function returns some sort of type then I should be able to TYPEP it
22:34:10
phoe
and if you are really paranoid about people making instances the wrong way, there's ways to guard againt that too
22:34:58
phoe
(defvar *paranoia* t) (defun make-foo () (let ((*paranoia* nil)) ...)) (defmethod i-i ((foo foo) ...) (when *paranoia* (error ...)) ...)
22:35:43
aeth
the lispy way is to use some arcane incantation of the MOP that nobody really understands, but that seems to work
22:37:11
verisimilitude
Yes, Lisp doesn't really support encapsulation or whatever one wishes to call it.
22:43:32
kakuhen
well, being able to access internal symbols easily is convenient when you're dealing with a library and wanting to use some utility function it has but marked private, or maybe extend a function in the library and unfortunately it invokes private functions
22:43:50
kakuhen
I've ran into issues like this when writing Clojure. There is a clever workaround to it, but it's much more gross than just :: in CL
22:45:28
aeth
(let ((x 42)) (defun x () x) (defun (setf x) (value) (setf x value))) ; the variable X is actually encapsulated by the functions X and (SETF X)
22:47:18
aeth
verisimilitude: The debugger may or may not actually expose x. All lexical variables are only expected to show up when (optimize (debug 3)) and otherwise could be eliminated. In this toy example, it's unlikely, but who knows? As long as the getter/setter accessors still work as expected.
22:47:37
verisimilitude
I've used Ada for several years now, and it's so much better than Common Lisp in this and other ways.
22:48:19
jcowan
"Data and procedures and the values they amass / Higher-order functions to combine and mix and match / Objects with their local state, the messages they pass / A property, a package, a control point for a catch — / In the Lambda Order they are all first-class.
22:48:20
jcowan
One Thing to name them all, One Thing to define them / One Thing to place them in environments and bind them / In the Lambda Order they are all first-class."
22:48:33
verisimilitude
I can define types in a package and totally control their subprograms, initialization, and even things such as assignment or equality.
22:48:58
aeth
There are other ways to use scope/names to encapsulate that may or may not be fragile/portable. e.g. uninterning a function after having callers using it, redefining an inline function, redefining a macro, etc.
22:49:07
jcowan
I think the CL answer to that is, If you want to chop off your foot, don't let *us* stop you.
22:49:32
aeth
verisimilitude: Yes, but by your own standards, you can probably use the Ada debugger to interfere.
22:50:19
aeth
Failing that (if the Ada debuggers somehow guard this), you might be able to use a cheat program (since they're mainly used for cheating in games) to edit the memory.
22:52:39
jcowan
See also Henry Baker's paper "How to Steal from a Limited Private Account -- Why Mode IN OUT Parameters for Limited Types Must be Passed by Reference" <https://web.archive.org/web/20191008050810/http://home.pipeline.com/~hbaker1/LimitedRobbery.html>
23:24:07
jmes
I want to initialize an object with some extra necessary parameters that aren't initargs. My current approach is defining an initialize-instance :after method with some keyword params which errors when the params are not given. Is there a better way?
23:25:06
jmes
The motivation for doing this is I need some extra information to perform the initialization but that information is not going to be stored in a slot.
23:25:13
kakuhen
what's wrong with leaving the slots unbound until you're ready to provide bindings?
23:25:40
kakuhen
alternatively you can do what people do for structs, where a slot defaults to an error being signalled
23:29:18
jmes
kakuhen: Well the object has a slot which should be computed based on some initial information coming from those other keyword parameters. But saying this aloud (so to speak) makes me realize I can probably expect that computation to happen beforehand, then pass the result into make-instance.
0:09:12
doomduck
being new to this, what do people use for the regular functional list/sequence manipulation? I know there's mapcar, but I'm imagining things like stuff in LINQ with all the where/first/flat-map/etc. ... I mean I know how to write these myself, it's more like "is there a nice/popular library?" ... not exactly sure how to search for quicklisp stuff
0:10:19
aeth
Not always functional but e.g. (loop :for i :from 0 :below 20 :collect i) or (loop :for i :from 0 :below 20 :sum i)
0:14:23
fe[nl]ix
aeth: I compiled that on my laptop, so not Ubuntu 18.04 but I want to test the build
0:15:06
fe[nl]ix
aeth: src/runtime/sbcl.extras is statically linked to libfixposix and openssl-1.1.1l with openSUSE patches
0:17:21
doomduck
aeth: is it recommended to learn loop instead of composable tools? it feels very very adhoc, but maybe that's just me being a noob, but not sure if i'm a fan of a big magic macro
0:18:26
verisimilitude
It's always preferable to use a standard function than some library, at least for me.
0:18:56
verisimilitude
It's not fun to audit some code and see a single usage of some library where LOOP would've sufficed.
0:19:45
fe[nl]ix
doomduck: learn loop because it's in the standard. its deficiencies won't matter until you want to write and maintain large amounts of code
0:20:54
aeth
doomduck: The big messy monoliths of LOOP and FORMAT don't have to be composable, but they can be used that way.
0:21:19
aeth
FORMAT can take in an arbitrary stream, while LOOP can be used as I just used it to return values
0:21:38
aeth
So you can mix-and-match them with other things even though some people probably (ab)use them as an all-in-one solution
0:22:39
aeth
for a toy example that probably isn't useful: (defun mapeven (function list) (loop :for item :in list :for evenp := t :then (not evenp) :when evenp :collect (funcall function item)))
0:23:27
aeth
if you're writing composable functions, you're probably defining them from fairly simple LOOPs