freenode/#lisp - IRC Chatlog
Search
22:49:39
jcowan
I would like some help figuring out what a "structure-object introspector" for programmatic use should give access to.
22:55:43
phoe
since a structure-class is a standard object, I guess you can view all of its slots as if you viewed any other standard object
22:56:43
phoe
the question is if the MOP says anything about the slots available in CLASS objects, not just STANDARD-CLASS objects
22:57:24
phoe
...not really, http://metamodular.com/CLOS-MOP/class-class.html says nothing in particular
22:57:45
phoe
so we can't really portably infer anything about the contents of STRUCTURE-CLASS objects by looking at CLASS objects
22:58:36
Bike
what you should be looking at is whether class-slots as a method on structure-class (it doesn't). mop doesn't define any standard class's slots
22:59:55
Bike
that said, implementations generally have one as an extension, or have class hierarchy changes for it
23:02:06
grewal
Is "Common Lisp in the Wild: Deploying Common Lisp Apps with Confidence" by Wimpie Nortje worth buying?
23:53:33
ealfonso
is there a webdav client? I only know of cl-webdav, which is a server, and cadaver which is CLI
0:20:25
jcowan
But my question is not "What facilities do existing CLs actually provide?" but "What facilities should such a library provide?" The first can be settled by investigation, the second only by design.
0:21:39
jcowan
The maximalist version would be something that given a structure-object would return its structure-class, and then functions or methods that given a structure-class would return the de re values of the keyword arguments to defstruct (that is, the actual functions etc., not their names).
0:22:29
jcowan
That would be sufficient, given a structure-class, to construct another structure-class just like it (using eval); if you don't want to use eval, there would also need to be a function that is the equivalent of defstruct.
0:24:01
jcowan
The first requirement is met by class-of, at least I hope it is. But is it actually necessary in practice to find out *all* those things about a given structure-object in order to usefully manipulate it without knowing the names of the copier, constructor, predicate, etc. etc.?
0:26:28
Bike
if i was designing from scratch i would drop the defstruct interface because it sucks, and instead have a new metaclass/whatever that indicates no redefinition is possible but still defines through defclass
0:40:52
jcowan
I see there is a QL library called deftclass that allows you to create a class as if it were a struct: that is, with minimum mental (and typing) overhead. I haven't explored it closely yet.
1:45:09
aeth
Bike: no need for that to be a from-scratch design since you could just deprecate DEFSTRUCT and have it simply be sugar for creating the metaclass (as well as the handful of other things it creates, like COPY-FOO and MAKE-FOO)
1:45:56
aeth
(well... to be deprecated in a future revision, which is even more meaningless than being deprecated)
1:52:37
aeth
A standard implementation of DEFSTRUCT on top of DEFCLASS could be an interesting CDR, if people still do that.
2:08:30
coltkirk
hello, i'm tying to use the maiden package to make an irc bot (in another room). https://pastebin.com/vSbm6vrJ there's the paste. I'm using slime/sbcl.
2:09:53
coltkirk
yes, I type the code in exactly as the official documentation states, but get several errors. The connection attempts but fails in a loop
2:21:03
Bike
i probably can't help you, but you'll get better advice if you describe the problem in detail, such as by putting the error messages in a pastebin
2:22:45
ealfonso
I like the explicit error handling approach of golang and google c++ statusor, is there something similar in lisp?
2:26:36
ealfonso
in c++ there is a type StatusOr<T>, which could be a value or an error. then there are macros: ASSIGN_OR_RETURN(auto value, file::GetFileContents(filename));
2:27:29
ealfonso
GetFileContents may return a status (error), which is propagated to the caller of the function containing ASSIGN_OR_RETURN
2:30:44
ealfonso
yeah, I wasn't familiar with the name "option type". I haven't seen much CL code using this pattenr
2:31:14
Bike
me neither. it's related to having things that return a value or nil, but more involved with the monad kind of stuff
2:40:51
ealfonso
the thing about returning nil for an error is that it makes it hard for a lower-level utility function to propagate the reason of an error up the stack to a caller who may be in a better position to handle it, e.g. display a message to the user, try again, etc. of course this could be done using conditions.
2:42:53
ealfonso
if-let doesn't give you context on where execution stopped because of a nil, and why
2:44:43
ealfonso
another problem with nil as sentinel for error is that it conflicts with "empty, no error"
2:50:05
ealfonso
one could write an "if-let-ok" macro, where the let expressions return an option type as 2-values, and with the "else" clause capturing the first non-ok option. but it would be an uphill battle since most existing code doesn't use this convention.
2:54:04
jcowan
https://srfi.schemers.org/srfi-189/srfi-189.html is a very new proposal for Maybe aka Option and Either types for Scheme, but there is no reason it couldn't be translated to CL. It also has a number of protocol converters that interchange between Maybe objects and various other conventions: value or NIL, 1 or more values or 0 values, etc. etc.
3:05:04
ealfonso
interesting. yeah, I'm curious to follow how that will go, and maybe it could be adapted to CL.
3:06:26
ealfonso
for now I will start using an "if-let-ok" macro pattern for new code and seeing how it goes
3:14:05
Bike
i feel like monads use some of their luster in an environment that doesn't use a lot of pattern matching
3:14:37
coltkirk
for what it's worth, although the new package 'maiden,' does not work as described, the former package 'colleen' seems to work just fine.
4:00:47
jcowan
The general monad library does what Haskell does under the covers: you pass around an object with procedures in it that contain the basic necessities.
4:10:50
beach
Speaking of DEFSTRUCT, I think I will do exactly what is suggested. It will just be a layer on top of the general STANDARD-CLASS features, with a separate metaclass and an additional superclass. So STRUCTURE-CLASS will be at the same level as STANDARD-CLASS in the hierarchy, and STRUCTURE-OBJECT will be a direct subclass of STANDARD-OBJECT, or a parallel one in case it is not allowed to have it a subclass.
7:46:27
phoe
I have a method on INITIALIZE-INSTANCE :AFTER that validates the keyword arguments and stuff
7:46:52
phoe
but I just came into a situation where I want REINITIALIZE-INSTANCE to also perform that validation
7:48:21
phoe
yes, I'm just thinking if I've been doing The Incorrect Thing™ for this whole time - using INITIALIZE-INSTANCE :BEFORE/:AFTER for validating stuff
7:50:42
beach
So logically, if it is UTC+2, it should be CEDT, but I don't much like those abbreviations, no doubt inspired from the US.
7:53:38
beach
My (admittedly small) family seems to get email from you, but I don't, and idurand does not get any either, I think.
7:54:48
phoe
my mail is there: https://mailman.common-lisp.net/pipermail/online-lisp-meets/2020-June/000013.html
7:58:51
flip214_
Can I print a simple-base-string with a max number of characters, with "..." appended if it is cut short? FORMAT doesn't do that, sb-ext:*print-vector-length* isn't standard. Is there some other *print-...* special I can use?
8:06:14
pve
flip214_: unless you're doing a library, I guess you could define a print-object method that checks if *chop-strings* is non-nil