freenode/#lisp - IRC Chatlog
Search
20:36:16
phoe
so you can create a fast-io buffer from a stream and then use fast-io read functions on that buffer object
21:06:52
phoe
I think that's what happens when sequence reading is not dominated by function call overhead
21:07:58
Josh_2
turns out I've been reading files (when not using alexandria) wrong this entire time
21:12:57
Josh_2
To be fair to fast-io when reading the same file 1000x I reckon my drive will be the bottle neck
23:11:07
jcowan
I'd like to see a use case where a condition type directly inherits from more than one condition supertype. Can anyone think of one?
23:12:57
phoe
for an application named FOO, (define foo-condition () ()) and then (define foo-error (error foo-condition) ()) (define specific-foo-error (foo-error) (...))
23:13:23
phoe
these are the two most obvious ones I can think of, the first one being actually mandated by the CL standard
23:13:47
jcowan
Okay, let me reformulate. Where neither of the direct supertypes are generic ones like simple-condition.
23:14:46
MichaelRaskin
nfs-condition could plausibly be a subtype of both network and filesystem condition
23:14:52
phoe
I guess it's like with classes; whenever you'd otherwise need multiple inheritance for whatever reason..
23:17:22
jcowan
MichaelRaskin: It seems to me that a NFS condition could be either a network or a filesystem condition, but hardly both. If you get a network error, you have no access to the file system, ugye?
23:17:45
phoe
(define-condition person-not-allowed-into-building (person-error building-error) ()) and such
2:07:01
thmprover
Random question: is there any strong consensus about package-name and directory structure? E.g., in Clojure, each namespace has its name be the file name, and subdirectory as prefix to namespace...does Common Lisp informally do likewise? Or is it all pushed in one giant package?
2:10:29
no-defun-allowed
In my implementation of Netfarm, there are 30 files, each about 50-70 LOC, in one package. There are about 80 exported symbols from memory.
2:11:55
PuercoPop
thmprover: There is no strong consensus, but most people use one package per project. There is a one package per file style supported by ASDF and some people do you prefer it. That style is the most similar to the one you'll find in Clojure.
2:13:16
no-defun-allowed
Another interesting example is a CLIM implementation; there are many files with (in-package :clim-internals), but they export symbols in some other packages (CLIM, CLIM-EXTENSIONS, etc). And my networking code and Petalisp have several modules, each with a package.
2:14:09
thmprover
I've just been sweeping my quasi-CAS into a ./math/ subdirectory of my project, it *feels* natural to include ".math." as part of the package name, but that's a Clojure habit I've acquired
2:16:35
no-defun-allowed
The Java teacher at this university told us that you name the files the same name as the classes so that you can always find the implementation of a class without using a search tool. Now, without using a search tool, how do I find the method toUpperCase in java/lang/String.java?
2:24:43
thmprover
One more question: what conventions are there for docstrings? I infer from the few examples given that UPPERCASE is used for function parameters, and when referring to other functions in my own codebase I defined I should wrap the `function-name' in quotes (like thus).
2:26:53
no-defun-allowed
I've always written parameters and function names upcased, or as normal if some noun matches the name of a parameter, eg (defun not-actually-subseq (sequence start end) "Return the contents of a sequence from the start to end positions" ...)
4:19:11
beach
thmprover: I find it best to have one directory, one package, and one ASDF system definition per *module*. Such a module can have several source files with one and the same initial IN-PACKAGE form.
4:20:10
beach
This way, another module can "use" another module by adding its system name to the list of dependencies in its own ASDF system definition.
4:22:47
beach
I have yet to see any advantages of a package per file. Every time it is brought up, I learn about contortions that are needed in order to avoid a single huge file for the module or a proliferation of packages that have no semantic meaning.
4:28:49
thmprover
beach: that is a sound and reasonable design decision. The problem I have is the modules are all really tightly coupled together.
4:30:06
beach
By definition a "module" has a very small interface to the outside world compared to its implementation.
4:31:41
beach
Ousterhout (I think it was him) calls them "deep" modules. He uses the image of a rectangle with constant area representing the code size, and the top edge representing the interface.
4:32:35
thmprover
Yeah, the program is a quasi-CAS with applications to physics (analytical mechanics and field theory), which makes it hard to separate out the code into modules. Ironically, it's for the same reason people called this stuff "beautiful" for a couple centuries...
4:35:32
thmprover
I'm sure it's going to be clearer as I continue plugging along, because right now my goals are fuzzy ("do science"). Later, after I have more infrastructure set up, it will become clearer (e.g., "handle celestial mechanics") and, hopefully, even clearer as I progress.
4:37:39
thmprover
beach: isn't Maxima exclusively a CAS? I was hoping to write some GOFAI to do science, in the sense of answering questions and solving problems (not doing any labwork, though).
4:37:47
oni-on-ion
lisp+repl is a good platform for having a scratch file, like a pottery floor. then seperate/order stuff out as things solidify
4:41:27
no-defun-allowed
You can write list processing and structure processing programs in Maxima, but the evaluation model is a bit wonky.
4:45:19
thmprover
I'll look at Maxima as a library, but the main goal is to have a Lispy Leibniz AI do science. Gordon Novak has a simple Lisp program that's a proof-of-concept of simple problems (you can try it online https://www.cs.utexas.edu/users/novak/cgi/physdemod.cgi).
6:00:17
oni-on-ion
how come defvar cannot provide both functionality of itself, as well as defparameter ?
6:58:19
beach
I am trying to figure out under which circumstances DEFMETHOD calls ENSURE-GENERIC-FUNCTION, and which what arguments.
7:00:16
beach
DEFMETHOD can't blindly call ENSURE-GENERIC-FUNCTION because it would need to supply some :LAMBDA-LIST keyword argument, and if it just supplies its own (with specializers and default arguments removed) then the generic function will be reinitialized without any reason.
7:01:06
beach
As long as the lambda lists are congruent, DEFMETHOD should at least avoid passing a different lambda list to ENSURE-GENERIC-FUNCTION.
7:03:13
beach
I guess DEFMETHOD can just call ENSURE-GENERIC-FUNCTION and rely on it to either reinitialize or signal an error.
7:06:51
beach
I think I need to re-read the MOP section about initialization of generic-function metaobjects.
7:21:41
beach
Does that mean that it's OK for a generic function to have methods of different classes?
7:22:15
beach
If so, DEFMETHOD should not pass the :METHOD-CLASS keyword argument to ENSURE-GENERIC-FUNCTION either.
7:23:20
beach
I mean, nothing prevents you from doing (defmethod thing ((x some-class)) (slot-value x '%thing))
7:24:32
beach
Yes, standard-reader-method and standard-writer-method are the ones used by the :READER/:WRITER/:ACCESSOR slot options.
7:24:56
no-defun-allowed
Yeah, but accessor methods have the slot definition accessible with accessor-method-slot-definition.
7:26:00
beach
Instead of going through SLOT-VALUE it is often possible to do STANDARD-INSTANCE-ACCESS instead.
7:26:04
no-defun-allowed
So (defgeneric foo (object)) (defmethod foo ((object number)) object) (defclass bar () ((baz :reader foo))) would create a generic function FOO with one STANDARD-METHOD and one STANDARD-READER-METHOD.
7:27:24
no-defun-allowed
So that generic function would require having methods of different classes.
7:29:18
beach
I guess I wasn't clear about that. I meant if you evaluate a DEFMETHOD with a class that is not a subclass of the METHOD-CLASS of the generic function in question.
7:30:18
beach
I think the METHOD-CLASS just provides the default when no explicit method class is indicated to DEFMETHOD.
7:31:19
beach
And, if so, the :METHOD-CLASS keyword argument should not be passed from DEFMETHOD to ENSURE-GENERIC-FUNCTION when the generic function already exists.
7:37:32
beach
Hmm, wait! So maybe DEFMETHOD should not call ENSURE-GENERIC-FUNCTION at all if the generic function already exists.
7:38:50
beach
I am saying that, because there is no information in the DEFMETHOD form that would justify a reinitialization of the generic function.