freenode/#lisp - IRC Chatlog
Search
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.)
10:39:56
phoe
if I want to use CHECK-TYPE properly inside SHARED-INITIALIZE, I assume that I must do that inside an :AROUND or primary method
10:40:13
phoe
and then CALL-NEXT-METHOD explicitly with all arguments, in case the CHECK-TYPE restart modifies the variables
10:47:22
aeth
phoe: You might be approaching the problem wrong. Personally, I type check at slot setting (to cover initialization and setters). Unfortunately, because this uses the MOP, I have to use ASSERT instead of CHECK-TYPE because the type isn't available at compile time. https://gitlab.com/zombie-raptor/zr-utils/-/blob/master/metaobject.lisp
10:49:12
phoe
can I use that with typechecking lists? like, assert that every element of the list is of type FOO
10:49:19
aeth
Well, yes and no. You can't rely on :type because SBCL doesn't typecheck at default optimization levels, which means that 80-90% of your users won't actually have typechecks there if you use :type
10:50:27
aeth
phoe: You can of course use a SATISFIES type, but I probably should just make it a generalized precondition/postcondition system since I'm using ASSERT anyway.
10:51:51
aeth
I should probably move the file I linked to into its own library because it's independent of my zr-utils and it's pretty much complete and usable, unlike the rest of it.
10:55:31
aeth
Well, it wouldn't just be type checked because I'd add a second slot for general assertions, mainly for sequence/etc. checking.
10:55:33
phoe
I'd actually be pedantic and manually expand a CHECK-TYPE in there to make it possible to pass the type dynamically at runtime, so the STORE-VALUE restart is preserved
10:57:05
aeth
phoe: How could you use a CHECK-TYPE at all in there? CHECK-TYPE's type isn't quoted. MACROLET?
10:57:31
aeth
I don't think I've ever used a MACROLET because they're nearly impossible to debug when someone else uses them.
10:58:48
aeth
Although if I guess if I did use a CHECK-TYPE it would probably make the other custom argument fairly obvious: checked-assertion...
11:19:14
phoe
(huh, writing this kind of stuff becomes suspiciously trivial once you've written your own condition system)
11:47:42
aeth
phoe: Oh, can you look over my conditions file? https://gitlab.com/zombie-raptor/zr-utils/-/blob/master/conditions.lisp
11:48:08
aeth
phoe: Those were the most common (error foo) patterns in my engine so I turned those into define-conditions a while back.
11:49:08
aeth
The idea of putting it in my utility library (and I might even move that into its own standalone library) is that that makes it easier for different libraries/programs to use the same conditions
11:51:33
aeth
Oh, hmm, I guess I don't. This is why I like exports at the top of the file. Makes it easier to spot that kind of thing.
11:52:04
phoe
a unit test suite would have caught this sort of thing - which is why I try to unit test every single thing I can
11:52:59
phoe
I'd split longer report functions into their own named functions, but that's a matter of taste
11:53:48
aeth
I probably will build those out of helper functions/macros at some point, but I haven't written enough to make clear patterns
11:54:01
phoe
and the starting vowel kind of stuff literally begs to be a helper function unto its own
11:55:34
aeth
yeah, I'm not very happy with that lambda in general... it was pretty tricky to write and iirc it was more about getting it to work correctly with the (REPL, not unit) tests.
11:55:56
aeth
Quite a few different branches, but they're all useful because of how common that error is
11:57:37
aeth
I could probably build required-input-error into another, third assertion in the checked-types metaclass