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
8:11:22
phoe
you cannot define a method on a standard generic function whose specializers are all standard as well
8:13:05
beach
The exact rule is, you can't define a method on a specified generic function that is applicable when given only instances of specified classes. And that rule is not restricted to Common Lisp. It is valid for (well written) libraries as well.
8:13:29
phoe
re previous discussion: now I need to figure out whether I want SHARED-INITIALIZE :BEFORE, SHARED-INITIALIZE :AFTER, or disqualified SHARED-INITIALIZE with CALL-NEXT-METHOD inside...
8:14:39
beach
phoe: You want a primary method or an :AROUND method if you need to modify the arguments in some situtations.
8:16:08
phoe
...oh wow! primary/around methods on SHARED-INITIALIZE is immune to that one issue that I've noticed with INITIALIZE-INSTANCE :AFTER constructors
8:17:30
pve
Where does it say you can't do naughty things with print-object? I can't seem to find it..
8:18:10
specbot
Constraints on the COMMON-LISP Package for Conforming Programs: http://www.lispworks.com/reference/HyperSpec/Body/11_abab.htm
8:18:21
phoe
"19. Defining a method for a standardized generic function which is applicable when all of the arguments are direct instances of standardized classes."
8:24:46
beach
phoe: Here is another thing that will make you a (slightly) better programmer. Standard FIND-METHOD takes either a class metaobject or a list (EQL object) in the list of specializers. But accepting a class name is an SBCL extension.
8:25:25
beach
phoe: You use this extension to remove a method on PRINT-OBJECT if the :REPORT option is absent.
8:29:59
matzy_
is it possible to check the types of each individual memnber of a list? i'm having a hard time finding function that does that on the hyperspec
8:34:47
beach
Or, if not, and if you can describe the types as a regular expression, you can use the RTE technique designed by Jim Newton and Didier Verna.
8:38:14
matzy_
its confusing, because i'm passing them as URL params in a POST body, but cl-dbi will only take them if I wrap each in double-quotes and even then smashes them into the same column with the column names included
8:39:22
matzy_
i'm admitting the first column which is an auto-incrementing id column from my INSERT, but I assume that OK
9:37:02
gaqwas
"In an unless form, if the test-form yields *false*, the forms are evaluated[..] Otherwise, if the test-form yields *false* (sic?), the forms are not evaluated, "
9:58:21
beach
aeth: I am not use to Hacker News. Is it possible, starting from that link, to back up in the history?
10:04:29
aeth
You can click on the [-] to collapse that thread. It's a bit hard to see the left line by default (I actually modify the style locally with a browser plugin)
10:06:39
beach
OK, thanks. I don't think this stuff was made for me. I wasn't looking to collapse the thread. I was wondering what prompted heisig to talk about CLOSOS, but I see now way to get to the previous message in the thread.
10:07:48
aeth
These sorts of websites are structured so that there's a link or a text post at the top, and everything else is a threaded reply to it
10:08:00
aeth
The top level is: Closos: Specification of a Lisp operating system (2013) [pdf] (metamodular.com) which is a link to https://news.ycombinator.com/item?id=23730107
10:09:38
aeth
You're welcome. And, yes, that website design was confusing to me, too, when I first saw it, probably 10 years ago.
10:10:19
beach
I can imagine. I don't have time to hang out in yet another place. Especially one with this kind of exchange. So I will probably always be confused.
10:10:33
aeth
It's a forum started by Paul Graham, so Lisp stuff sometimes trends on it, but not anywhere near as much as it used to.
10:11:35
aeth
It is the only known piece of public software written in Arc, the Lisp language that flopped. (Other than Arc implementations themselves, of course.)