libera/#commonlisp - IRC Chatlog
Search
14:52:59
pjb
Perhaps somebody at google will implement an AI to summarize a video, and transform it into a multimedia stream that could be absorbed by brains in high speed. Or perhaps we'll have to wait for neuralink to provide the brain downloading feature…
14:53:11
rain3
the video above actually was quite good in comparison with others. I've downloaded them so that I can play at 10x with vlc player , then I deleted all of those which only had examples from the readme of the lib
15:36:39
zos
Hello all, I am interested in learning common lisp. I have started working my way through Practical Common Lisp. Right now I am using SBCL with Doom Emacs. In some tutorials I have come across mentions of roswell and am wondering if it is worth setting up from the start.
15:37:47
rain3
it's good to set it up so that you can easily switch between different versions of SBCL when needed
15:40:20
Lycurgus
i believe in n chances, especially if somebody else does the m+1 of them, in my case m is like 2 -4
15:42:57
zos
That sounds like good advice - it is going to take some time before I am likely to need to worry about deployment. Thank you for your help
15:44:07
beach
zos: #commonlisp is not really for newbie questions, in case you want to ask such questions at some point. They are tolerated though, and if they become too trivial or too numerous, you might be asked to go to #clschool.
16:14:56
phantomics
When I eval: (defvar foo 123) (let ((set-foo (lambda (x) (setf foo x))) (foo foo)) (funcall set-foo (setq foo 55)) (* foo 3))
16:16:11
phantomics
Why doesn't the set-foo function defined in the (let) affect the top-level binding of foo? The function is defined before the value inside the (let) form is locally bound to foo
16:18:31
phantomics
Ok, so this method would work if foo was a lexical variable defined in a (let) form containing the code rather than a special variable?
16:19:15
jackdaniel
daily quiz: what's a practical value of (apply foo (car bar) (cdr bar)) compared to (apply foo bar) ;?
16:19:47
beach
phantomics: It depends on your definition of "work", but yes, you can close over lexical variables.
16:24:33
jcowan
Sure, but my claim was that there are no global lexical variables, as you cannot wrap a let around your program (becaause too many things in it insist on being top-level)
16:25:27
jackdaniel
there are file-local-variables (in the standard it is i.e *readtable*, but there is also asdf extension that gives you that)
16:27:10
beach
jackdaniel: I can imagine if foo is something like #'apply, and (car bar) is something like #'reduce, but I am not sure.
16:27:18
jackdaniel
of course one could argue that the practical application I have in mind can't be considered a good style of programming
16:28:33
jackdaniel
however you could specialize the first argument on null as a fallback, and then bar could be nil
16:39:13
pjb
zos: have a look at http://cliki.net/Getting+Started http://cliki.net/Online+Tutorial and in general, http://cliki.net
16:39:56
j-sh
What is the current best way to use the GNUstep GUI toolkit (and maybe its RAD tool Gorm) with common lisp?
16:43:27
pjb
phantomics: yes, it would work with lexical variables, but the question is why did you make a temporary binding of foo in your let?
16:44:38
pjb
phantomics: it's not wrong, that's the point of dynamic variables: they let you shadow temporarily the previous binding, during the execution of a let body. But the point is that if you want to have the previous binding mutated, you should not temporarily shadow it!!!
16:45:14
pjb
(defvar *foo* 123) (values (let ((set-foo (lambda (x) (setf *foo* x)))) (funcall set-foo (setq *foo* 55)) (* *foo* 3)) *foo*) #| --> 165 ; 55 |#
16:46:16
pjb
phantomics: note that defvar declares the variable name as special; this is a global declaration that cannot be removed or shadowed. So it is important to use the earmuff convention foo -> *foo* to avoid damaging the normal variable names.
16:48:29
pjb
j-sh: the first problem is that there are different Objective-C runtimes: Apple's runtime, GNU runtime, cocotron runtime (used on MS-Windows I believe).
16:49:49
pjb
j-sh: the next problem is the FFI from lisp to Objective-C; there are some nice things: the objc runtime is a pure C API. There are some more difficult things: depending on the runtime and the libraries or frameworks, it's not always easy to introspect the API; we still have to process the headers, and this is not easy (failproof) to do it automatically.
16:51:19
pjb
j-sh: ccl provides a FFI that works with Apple's runtime. I don't know how well it could work with GNU Objective-C runtime. There's an Objectiev-C FFI that could work with GNU Objective-C (and possibly cocotron, IIRC), but AFAIK it has bitrotten.
16:52:18
pjb
even ccl uses a ffigen that is a patch of Apple gcc version 4 that is entirely outdated and therefore is completely bit-rotten; I don't know how to generate the cdb files ccl FFI requires to deal nicely with frameworks on current systems.
16:53:42
pjb
In short, it's a mess, and we'd need to re-implement from scratch an CL -> Objective-C FFI that would work nicely for all runtimes, and all frameworks. But it's not a small project.
16:55:19
pjb
j-sh: Have a look at this objcl library (which is a reader-macro to give [recipient message:arg with:arg] syntax over ccl objc FFI: https://github.com/informatimago/lisp/tree/master/objcl
17:01:11
phantomics
pjb: I know I'm using weird conventions in this code, that's because it's for the output of my APL compiler, and APL has some odd conventions for implicitly shadowing variables but also has ways of modifying variables at the top level of their scope
17:06:02
pjb
j-sh: you can still do something. Have a look at https://cliki.net/com.informatimago.hangman
17:07:08
pjb
j-sh: well, http://git.informatimago.com/viewgit/index.php?a=tree&p=public/games/hangman-cocoa-objc&h=6a4c99a8d52e6cdaf08b28dffa67797dab8f9a89&hb=99a80c170985b9b3a753025c00870c63a94cf678 ; I don't know if I left the gnustep version on github.
17:08:06
pjb
(nope. the gnustep/ subdir only contains objective-c code… ; as I said, the problem is difficult and has not been worked on ever)
17:09:00
pjb
j-sh: basically, CL is a not used by a lot of programmers. GNUstep is not used by a lot of programmers. CL with GNUstep is used by a handful of programmers and we don't have the resources to make any progress on the combination.
17:09:21
pjb
j-sh: as beach said, it has been a long time since we talked about GNUstep in #commonlisp
17:37:52
pjb
lotuseater: j-sh: so a first step would be to define a complete FFI to the gnu objective-c runtime, to the apple objectiev-c runtime, and possibly others (cocotron, etc).
17:38:32
pjb
lotuseater: j-sh: next, define a higher level CL to objective-C interface using introspection and working with all runtimes.
17:38:52
pjb
lotuseater: j-sh: finally, use my reader macros to be able to use the nice Objective-CL syntax ;-)
17:40:09
pjb
two problems: 1- dealing with C macros in the objc runtime headers. 2- dealing with the various structure layout (packed/not packed, 32-bit/64-bit, and other #ifdef).
17:41:20
pjb
(perhaps introspecting the debugging symbols in the shared libraries of the run-time, but this adds a new complexity (gdb symbols, dwarf symbols? what to do if stripped without debugging symbols? etc).
17:52:40
j-sh
pjb Thank you for your extensive answer, I didn't know that it would be that difficult to use CL with GNUstep.
17:52:41
j-sh
I personally think that it is a shame that GNUstep didn't get the recognition that something like GTK (it is even older than GTK AFAIK) got, but I guess there aren't many people that want to touch an Objective-c codebase especially since it has the "Apple stigma" to it and even Apple themselves try as hard as possible to deprecate Objective-C
17:56:15
pjb
j-sh: well, it's not that it's difficult. It's labor intensive to do something complete.
17:56:49
pjb
j-sh: if you just want to send a few message, you really need to FFI a few functions in the runtime. You can easily do that.
17:57:35
pjb
j-sh: if there were bindings for other languages to GNUstep, that could indeed make it more popular.
17:59:10
j-sh
pjb There are apparently bindings for Java, ruby and Smalltalk, but I'm not sure how much they are maintained.
18:01:57
pjb
For example, one problem is that the code used to encode the types are defined with #define in the runtime.h header. So CL needs either to parse those headers, or to hardwire the encoding for each compiler/runtime.
18:04:58
pjb
j-sh: For example, you can cffi:defcfun objc_msgSend and sel_getUid, and then already you can send messages to objects.
18:05:32
pjb
but in CL you'd want to be able to introspect the classes and objects. So you'd want the full monty.
18:06:26
pjb
j-sh: try: (defclass foo () ((x :initarg :x) (y :initform 42))) (inspect (find-class 'foo)) (inspect (make-instance 'foo))
18:07:02
pjb
you'd want to do the same in CL for Objective-C classes. (even more, since in Objective-C the methods are attached to the classes, so you'd also want to list the methods).
18:17:11
lotuseater
a C# software developer he could also extend his language or that it couldn't be different in CL ^^ hard to make him clear why not
18:57:38
jcowan
Anyone who asks you "But why would you want to do *that*?" when talking about cross-language comparison should be resolutely ignored: nobody "wants" a feature they've never heard of, because they've learned to work around it or not to want it or are simply clueless. (However, the question does make sense within a single language, because there may well be a different way to achieve the same effect within the language.)
18:59:48
lotuseater
I also tell that's an experience no one can just tell you, you must make it yourself to really get the difference.
19:06:40
lotuseater
haha and just because something is used by more people or there are many (aweful) book about it means it's better (just better marketed)
19:09:35
jcowan
This is a highly speculative question: can anyone see a use case for a separate class hierarchy allowing you to create generic functions that aren't related to ordinary generic functions?
19:10:34
tfeb
lotuseater: 'popular does not mean good: it merely means good at being popular', as someone once said.
19:13:09
aeth
jcowan: type-based generic dispatch in CL. https://github.com/markcox80/specialization-store/
19:13:21
aeth
types allow you to dispatch on numbers/sequences/arrays that don't necessarily have distinct classes
19:13:58
aeth
since you could e.g. (simple-array octet (* *)) as a type for 2D (unsigned-byte 8) arrays (assuming octet is defined as such)
19:14:22
aeth
jcowan: I wouldn't be surprised if there are other distinct generic function systems, too, perhaps more close to what you're looking for
19:15:15
jcowan
Clojure allows uou to create independent class hierarchies, but I can find no explanation of why you'd want to.
19:16:50
aeth
and perhaps you can't do that, if it's a well-specified language in a way that's incompatible with the host language
19:17:13
aeth
but that way at least you can use built-in generics even though you can't use the built-in class hierarchy
19:24:32
pjb
jcowan: independent class hierarchies are usually an illusion, there's normally a TOP class (eg. T in CLOS).
19:26:20
pjb
jcowan: that said, in CLOS, playing with metaclasses, you can probably implement separate subhierarchies according to your wishes.
21:41:55
phantomics
Hey, another question. When a local binding is created for a dynamic variable, functions defined even outside the scope of that local binding will use the local binding, correct?
21:42:15
phantomics
(defvar foo 13) (defun set-foo (arg) (setf foo arg)) (let ((foo 3)) (set-foo 50) (+ foo 10)) foo
21:42:43
phantomics
The (set-foo) inside the (let) form doesn't actually change the top-level value of foo, even though the function is defined outside
21:47:02
pjb
lotuseater: the only advice I have for Bjarne, unfortunately, is to ask to be interned in a lunatic asylum.
21:48:01
pjb
phantomics: you don't have _local_ bindings for _dynamic_ variables. It's like asking what taste is the color blue? it's meaningless.
21:48:26
phantomics
I know that the dynamic vars have a value stack and a value gets pushed onto the stack within that (let) scope
21:49:43
pjb
phantomics: the set-foo mutates the binding of the dynamic variable foo that is active WHEN the function set-foo is called.
21:50:13
pjb
phantomics: in set-foo, there is absolutely no consideration for WHERE the variable foo is bound. Only WHEN it is bound.
21:51:28
pjb
Note: you can define global lexical variables using symbol macros. Search for a defglobal or deflex in libraries.
21:51:37
phantomics
The workaround, as far as the April compiler is concerned, is to prefix the internal representations of all lexical variables with something
21:53:56
phantomics
And then if they write a function like {foo←5 ⋄ foo+⍵}, a lexical variable called something like "𝕏foo" that shadows the value of the external "foo" is instantiated in a (let) form
21:54:08
pjb
So you're implementing lexical variables with dynamic variable when you have a language that already has lexical variable? Why? Are you masochist?
21:55:07
phantomics
It creates implicit shadowed lexical variables when you assign a value to something inside a function
21:55:47
pjb
Ok, so you have toplevel variables that are dynamic and local variables that are lexical, and the local lexical variable can shadow the the toplevel dynamic variable?
21:56:04
pjb
In that case, indeed, you need some kind of renaming or use a different namespace (package).
21:56:57
phantomics
The tricky part is that APL has a type of function that can reassign the global variable outside of a function's scope
21:57:35
phantomics
But given a lexical variable's name, I need to be able to find if it is shadowing a dynamic variable
21:58:44
pjb
(mapcar (lambda (lexical-apl-variable) (cons lexical-apl-variable (gensym))) lexical-apl-variables) to build an a-list mapping the lexical-apl-variables to lexical-lisp-variables.
21:58:48
phantomics
If I rename them to gensyms how do I find their corresponding external dynamic var symbol? Enter it all in a hash table? The prefix system is simpler, and double-struck letters are illegal in April var name so there's no chance of collision
21:59:19
pjb
You find that before, by looking up the apl-variable in a global-dynamic-apl-variables list.
22:00:18
phantomics
That seems cumbersome when I could just remove the lexical var prefix and look for the existence of a dynamic var by that name
22:01:43
phantomics
April is designed to produce relatively readable compiled code for the purpose of debugging
22:02:45
phantomics
APL converted into Lisp designed for readability, I've built a lot of stuff including some reader macros just to make the output more readable
22:03:06
pjb
note: lexical variables are not accessible from "outside" the function, while global variables are accessible from anywhere.
22:03:44
pjb
therefore I would use a package such as "APL-VARIABLES" to intern the names of the global dynamic variables, and another package "APL-INTERNALS" to intern the name of the lexical variables.
22:03:48
phantomics
The concept of "global lexical variables" is interesting though, I may check into those tools you mentioned in case they're useful
22:04:36
pjb
Well, you'd have APL-VARIABLES:FOO and APL-INTERNALS::FOO. You wouldn't have to export symbols from APL-INTERNALS.
22:04:51
phantomics
April already supports multiple workspaces, each of which is implemented as a package, so that means I would have to have two of those packages for each workspace
22:06:09
pjb
having APL code generate packages with exported symbols only for the "public" stuff and other packages for the internals would be clean.
22:06:31
phantomics
April is intended to be highly interactive with Lisp; each workspace is a package, all variables you create can be accessed from the Lisp instance.
22:06:58
phantomics
If all the lexical vars are interned in a "sub-package" that could be fairly clean, no one would need to do much with the lexical package
22:42:17
char
Is there any good forward+reverse proxy for common lisp? I couldn't find how to forward http tcp sockets with hunchentoot