libera/#commonlisp - IRC Chatlog
Search
17:24:56
Bike
i see, and this works by specializing the mop method applicability methods. so typep wouldn't work. which is fine, it's still interesting. i should put more thought into what an extensible type system could look like.
17:48:21
phoe
jackdaniel: aren't all classes named in portable CL if we skip the MOP? even classes that have been removed from the global environment still have their names intact, AFAIK
17:51:15
jackdaniel
the gist of deliberations was whether the term "named" applies to the state in the environment or to the result of class-name invoked on the class
17:51:46
Bike
you can use (setf (find-class name) nil) and (setf (class-name class) nil) to remove any name association even without the mop.
17:52:02
Bike
and in fact it looks like there's a note on class-name saying "The name of an anonymous class is nil."
17:52:36
jackdaniel
nope, it is accessor: http://www.lispworks.com/documentation/HyperSpec/Body/f_opsetf.htm
17:52:36
phoe
also (defclass foo () ()) (setf (find-class 'bar) (find-class 'foo)) (class-name (find-class 'bar)) ;=> FOO
17:53:14
Bike
(setf find-class) mutates the environment but does not affect the actual class at all. (setf class-name) does affect the class (and not the environment)
17:53:28
phoe
"If S is a symbol such that S =(class-name C) and C =(find-class S), then S is the proper name of C. For further discussion, see Section 4.3 (Classes)."
18:24:28
jackdaniel
alright, starting from tomorrow I will be rather offline until after Holiday, so Merry Christmas and Happy Hannukah everyone :) o/
18:41:47
jeosol
I have a question guys relating to maintaining deployed CL resources. Now I have looked at two options: 1) Docker containers and 2) just a repl. For updates, rebuilding my images takes longer for sure (I also use multi-stage build) but with repl option, I push updated code to the machine and can send update command the running repl is updated
18:42:45
jeosol
Now I get for easier deployments, CI/CD, devops, etc, containers are better. I wanted what you guys are doing especially at is also related to image-based development in CL. Thanks
18:43:19
jeosol
I should add the second option appears ok for now, I just have a small machine (dev) and another for the prod testing, so nothing super complicated
19:51:04
opalvaults[m]
I'm a little confused on the use of a lambda here in Practical Common Lisp.... (full message at https://libera.ems.host/_matrix/media/r0/download/libera.chat/674d99d9c802ef3b4a88a04363f1155bb0fa6425)
20:09:18
opalvaults[m]
Bike: I feel like remove-if-not could also be used here to select optional arguments?
20:10:29
Bike
what's wrong with keyword arguments and what does that have to do with returning a function
20:16:29
concrete-houses
I remember paul graham saying in one of his essays that they didn't use sql database... in VIAWEB
20:17:23
hayley
And see <https://plover.com/~mjd/misc/hbaker-archive/letters/CACM-RelationalDatabases.html>
20:20:33
opalvaults[m]
Bike: nothing wrong with keyword arguments, I'm just curious if there's a way to select keywords out of a list of database entries in an easier way than using a lambda expression. Also, do arguments in a definition automatically get passed to a lambda function?
20:22:02
hayley
concrete-houses: Most of the time I am parsing whatever data format I am given, but arguably that's not a lot of data.
20:24:09
Bike
opalvaults[m]: for a real program using a database you would probably use a better representation. this is just an introductory example for the book.
20:28:12
opalvaults[m]
Bike: gotcha, okay i'll read on then. it looks like this intro is just a quick and dirty and not meant to explain everything all at once. that's interesting how lambda (cd) is able to parse over every argument passed into a procedure
20:30:24
opalvaults[m]
i get the scope of what it has access to, i suppose what is confusing and interesting to me is that lambda automatically iterates over all define arguments. it's not obvious that lambda should be able to do that coming from an Algol related family.
20:31:06
opalvaults[m]
I'm conditioned to need to iterate over **kwargs (or some such), and test accordingly
20:37:01
hayley
concrete-houses: To a zeroth approximation, having direct pointers rather than looking through an index would be faster. But I'd still like to see that if the join exposes multiple matches, i.e. the program follows a one-to-many relation.
20:39:35
concrete-houses
interesting that the wikipedia page for transitive closure mentions graphs -- aren't they all the buzz now?
20:40:26
concrete-houses
wow maybe I have been watching too much Alan Kay but it seems a lot of decades old computing was smarter
20:43:24
concrete-houses
What did Paul Graham mean when he said we faked continuations with closures?
20:53:57
concrete-houses
Work does a hunting license lottery...... So they have all these licenses fir 4 seasons and different game.....and need to randomize for 15k or so custoemrs, and then the first 'randomly' pciked customer gets the license that is the top one in a list of licenses they want I think 10 it limit to that list.....as licenses are won the availabel licesne count must be reduced by 1 or if the winner
20:54:03
concrete-houses
is a team leader, by the team size, and each team member gets the same lciense.... now in our implementation the non team leader sare in the lottery which seems silly to me.... but would a lisper be able to get random numbers adn run such a lottery pretty easily?
20:54:51
concrete-houses
if the license count is not availble then the second choice is won, if available
20:55:13
White_Flame
concrete-houses: of course non-relational databases are faster. Data is clustered and in specific application-aware format
20:59:08
concrete-houses
https://plover.com/~mjd/misc/hbaker-archive/letters/CACM-RelationalDatabases.html yes I think he does.
22:18:55
scymtym
Bike: the protocol definition would also make associated specializers and type specifiers for the "roles" of the protocol: https://gist.github.com/scymtym/c4b842f04fe37ef52745d3ed3ea97e50
22:29:17
opalvaults[m]
i have to wonder if people who dive into CL just dread working in other languages and/or lose interest in all other languages after learning CL.
22:32:00
scymtym
Bike: mostly just CLOS and MOP. being able to spell the specializer like that uses SBCL's specializer parsing/unparsing machinery which is historically but not technically related to generalizers. that's only syntax though. one could construct the method by other, slightly less convenient, means
22:33:24
scymtym
and the type specifier is just syntax for (satisfies GENERATED-GENERIC-FUNCTION) where GENERATED-GENERIC-FUNCTION returns true for that same specializer and false otherwise
22:34:33
scymtym
so in summary, a class conforming to a "role" in a protocol can be "statically" checked, used as a specializer and used as a type
22:50:35
rotateq
hayley: i often see much good DSL potential as a niche one can do, maybe for the future
22:50:43
dre
opalvaults[m], I am a python programmer as well, but I'm learning common lisp and I want to find a way to cram it into more of my projects. (keep in mind, I don't often make projects)
22:51:21
hayley
In my opinion (which involves no experience with business), using a language you don't know at work is pretty risky.
22:52:55
hayley
I didn't like Java or Python very much when I did university courses with them, but I attribute that to the university.
22:54:06
rotateq
yes here at the university there's a "functional programming" course with Haskell (of course) but the prof is not good at all and this gets the people a superficial idea of things
22:54:06
dre
hayley, i really liked python, at university, simply because it was an alternative to matlab.
22:54:09
hayley
But trying to do interactive development in Python was tricky, as it appeared things would refuse to reload unless I didn't do a topographical sort in my head.
22:55:18
hayley
...and we actually had to write somewhat fast code for one assignment, which scared me, but I somehow managed to find the best solution by accident, and the performance problems were really in a library we didn't write.
22:56:00
dre
I had like, half a day left and we had to implement some sort of robotics algorithm. There was some "matlab on computer to rpi robot, sent over wifi" contraption that was a pain
22:56:32
dre
and we were like, getting so late, and panicky about it (cause robot is not moving, close to deadline)
22:58:17
dre
and I'm like "welp nothing to lose lets try this" - python on robot. "if direction is not None and indicator is type(int): foo()" -- worked, saved the assignment, and have been diggin python for a while since.
22:59:05
dre
but yeah, gotten to the point where there's complaints, and having dabbled in lisp, I get it; I have my foot in the door, and I want more :)
23:04:22
dre
as a newcommer, Land of Lisp was a much more fun start into the language, but PCL has some great tibbets in it
23:05:57
dre
I'll probably work my way though PCL soon. I did some of AoC in common lisp which was also a great experience
23:06:14
hayley
It's very loose with names. Been a while since I read it, but beach had a list of mistakes in the first few chapters <http://metamodular.com/Books/land-of-lisp.html>
0:14:37
opalvaults[m]
*no-defun-allowed* I love that guys writing. I believe he wrote a paper about a common lisp operating system that I really liked.
0:15:05
opalvaults[m]
hard to find through the website, thankfully i bookmarked it. For anyone interested: http://metamodular.com/closos.pdf
0:28:21
Spawns_Carpeting
I am not exactly sure what the type is in the first place, whether its a vector or hwat
0:29:00
Spawns_Carpeting
i could setup a local irc server for testing but it would be easier to uh, just know the type
0:29:30
Xach
Spawns_Carpeting: it's been a while, but i believe it's a vector of octets. octets-to-string will convert it if you like.
0:35:51
Spawns_Carpeting
how can I use sb-bsd-sockets inside of an asdf package? Do I need to :use something, or just require it?
0:43:21
Spawns_Carpeting
I am trying to logically work my way through this so I know how to do it in the future. I see that sb-bsd-sockets is itself an asdf "system", but I am not sure if the :use part of a defpackage imports systems, packages, or what exactly
0:45:35
Xach
Spawns_Carpeting: so, if you have a project with an .asd system file, :depends-on (#:sb-bsd-sockets) is a thing you could have in your file.
0:46:11
Xach
to refer to external symbols in the sb-bsd-sockets package without a prefix, you could :use #:sb-bsd-sockets in your defpackage form.
0:48:24
Xach
Spawns_Carpeting: it makes it so you can refer to their external symbols without a package prefix
0:48:47
Xach
so after (defpackage #:foo (:use #:cl)) (in-package #:foo), you can refer to CL:CAR without the "CL:" part
0:49:15
Xach
If you don't :use, you can still refer to them just fine - but you have to write the prefix.
0:49:59
Xach
there are a few ways to manage that sort of thing. importing is one, and shadowing comes into play when you :use multiple packages when there's a conflict
0:56:00
Xach
Spawns_Carpeting: it's a way to use a symbol for its name without interning it in any package
0:56:20
Xach
the real critical part is the name of the symbol - the #:... is syntax for a particular kind of symbol.
1:05:53
rotateq
dre: this dialect seems to be domain specific for programming robots too: https://staff.aist.go.jp/t.matsui/eus/
1:13:06
hayley
Per https://staff.aist.go.jp/t.matsui/eus/manual/node6.html#SECTION02013000000000000000 it seems unlikely.
1:28:50
rotateq
there's this interesting paper metacircular semantics for CL special ops surely you know it
2:04:00
Spawns_Carpeting
dash defines a bunch of handy functions for working with lists, like flatten, filter, map, take, take-last, take-while, etc etc etc
2:08:55
rotateq
Spawns_Carpeting: and it can also curry your meals :) or you do the alias "to schoenfinkel"
2:22:07
jstoddard
Hi everyone, say I have a class with three slots that have accessors a, b, and c. I want to create a subclass--all the methods on the original class make sense for my subclass, but it would make more sense to users if the accessors were named x, y, and z.
2:22:24
jstoddard
Is there a straightforward way to "alias" the names of those accessors for my subclass?
2:24:16
Xach
and when implementing a protocol it's not unusual to implement it with method names that don't match the slot name
2:27:35
jstoddard
I assume I can do the same thing with initargs -- (defclass subclass (class) ((a :initarg x :accessor x) ...))?
2:37:26
Spawns_Carpeting
how can i convert a string into a format suitable for using in socket-send?
2:39:04
rotateq
jstoddard: and for subclasses you of course can rewrite other options like initform or allocation
2:45:48
rotateq
just cause I see it now, it's a convention to place earmuffs around global parameters :) so one can say from reading "ahh that's a global parameter". and also wrapping constants with plus signs
2:46:54
hayley
And I wrote babel:string-to-octets after, with the babel: package prefix. Granted, IRC and programming is asynchronous. But you probably also want babel:octets-to-string instead of octets-to-string, to avoid the same error when you receive a message.
2:49:03
Spawns_Carpeting
i suppose it probably just loops through the string an creates a vector of char codes
2:52:11
rotateq
with it you load/build systems that define packages, which are container for symbols
2:56:05
jstoddard
Things work! You all just saved me potentially hours of tinkering around to figure out these little details about accessors, that I can now spend learning about what I'm trying to do (raytracing, if anyone cares). So thanks!
2:58:25
rotateq
improving the raytracer from Alexander Lehmann also with parallel and concurrent calculation or such could be a good go-on project and for rendering more complex scenes
3:04:08
jstoddard
Oh, he has videos up about raytracing in Common Lisp. Here I am working through a C++ tutorial rewriting things in Lisp.
3:08:21
jstoddard
Yeah, I never really got into C++, so it's kind of like speaking Spanish but trying to read Portuguese.
3:09:01
rotateq
One of the first big differences between C++ OO-system and CLOS is the decoupled classes and methods that are specializations to generic-functions with also possible method-combinations.
3:17:34
Spawns_Carpeting
how exactly do vectors work in lisp? I can't seem to get vector-push to work
3:18:42
hayley
(defvar *x* (make-array 10 :adjustable t :fill-pointer 0)) (vector-push-extend 1 *x*)
3:19:09
rotateq
or vector-push if it has a fill-pointer that is at the moment smaller than (1- length)
3:19:23
hayley
Er, the vector needs to have a fill-pointer, but it doesn't have to be adjustable for VECTOR-PUSH...
3:19:46
hayley
but I would recommend using an adjustable vector and VECTOR-PUSH-EXTEND, unless you know you definitely don't want resizing semantics.
3:20:56
hayley
A Common Lisp vector is just a one-dimensional array, whereas some languages use "vector" to mean a resizable one-dimensional array.
3:29:09
rotateq
ah okay. in CL they are also vectors specialized to element-type character and thous you can look up their length directly
3:32:55
Spawns_Carpeting
darn i am getting errors trying to decode the bytes from the socket into UTF8
3:39:38
hayley
I think something is going wrong if babel:octets-to-string doesn't work, but no one would know what, if you only say you are "getting errors".
4:00:35
Spawns_Carpeting
do I use setf of setq to set slots that have been brought "into scope" with with-slots?
4:06:32
Spawns_Carpeting
the problem was, I had the loop setup to read from socket until the message delimiter appears at least once in the connection buffer, but it was looping forever
4:06:53
Spawns_Carpeting
i fixed it though, i forgot to concatenate the buffer with the data from the socket
4:37:26
Spawns_Carpeting
what would something like (setf (struct-field struct) nil) do in terms of bytecode?
4:37:56
Spawns_Carpeting
a better question might be what exactly is going on when using the slot accessor functions
4:39:27
beach
There would likely be native instructions to compute the address of the slot and then store a new value at that address.
4:41:08
Spawns_Carpeting
I am thinking of a high level bytecode type of thing. just curious because I am still working on my personal lisp project, but haven't got as far as structs and classes yet
4:41:40
Spawns_Carpeting
im still in the early stages of compiling it actually, progress has been slow
4:42:37
Bike
if you're asking what the lisp compiler compiles into, it's not necessarily bytecode. sbcl and ccl both compile to native code for example.
4:43:20
Bike
if there was bytecode it would be the same way you do a structure access in pretty much any kind of instruction set, though? memory set kind of deal
4:43:35
Spawns_Carpeting
i mean, what kind of bytecode would it look like on a bytecode based lisp interpreter
4:44:39
Bike
doesn't have to be specialized. it's just an index into a structure and then a load from memory. or store to memory.
4:48:00
Spawns_Carpeting
i seem to catch on to the whole compiler thing a little more slowly than others
4:48:41
Spawns_Carpeting
i guess in my VM a struct slot accessor could just put a reference to a struct field on the stack or something