freenode/#lisp - IRC Chatlog
Search
21:36:48
jmercouris
so, I'm working on S-XML-RPC with ambrevar on Gnu/Linux, here's what happens when he tries to receive a message in SBCL https://gist.github.com/jmercouris/756d0d10d4ca9aa0a1ebfe9261e9d1d2
21:42:56
jmercouris
if anyone does see something fascinating in the REPL output, please send me an email: john@atlas.engineer
22:56:21
didi
Hum, I think this is the first time I want to use a symbol that is locked to define a function (INTERSECTION).
0:12:42
equwal
They're important. Just make a package so you wont clobber cl-user and you're good to go.
0:14:43
didi
equwal: Ah, yes. I do it like that. I have some packages (and their systems). But I don't think I've played any advanced game yet.
0:20:54
equwal
If you are working from in a package you can make it external but not import it so you access it with package-name:intersection leaving the standard alone.
1:06:40
equwal
How can I change a regular character like #\f to a read macro without a dispatch character? This way I can call a read macro as if it were a function (fn...)?
1:09:56
no-defun-allowed
(defmacro brainfuck (code) `(lambda () (brainfuck-interpret ,(symbol-name code)))
1:10:21
equwal
I got it working like this: #defmacro/g! name (z) `(let ((,g!y ,z)) (list ,g!y ,g!y))
1:12:07
equwal
It does parentheses by just counting until there is an extra one on the right. I am trying to set it up such that it can be called with (defmacro/g!...) making #\d the macro-character. Unfortunately I can't do it without making it impossible to defun declare, etc.
1:13:09
Bike
putting a reader macro on d means when the reader sees a d, you take over parsing. you can't just do it halfway.
1:14:56
equwal
Well I could do that, but I was hoping to get it semantically the same as the book so I could send it to the production code repo.
1:15:45
Bike
there is no such thing as a fake function. i'm not sure where you got the idea that there was.
1:16:47
equwal
I could get it to work if, for example, I set the reader to activate a reader macro if it reads "DEFMACRO/G!"
1:18:03
Bike
as an example, if you had '(defmacro/g! ...), with your scheme funny things would happen.
1:23:19
no-defun-allowed
all i can suggest is to write a macro that takes the code as an argument, takes the SYMBOL-NAME of the symbol and uninterns it
1:40:58
no-defun-allowed
not a reader macro, just a normal macro which reads in your code as an an argument, eg (brainfuck [+.>])
1:43:11
equwal
I used the brainfuck because I though I was simplifying my question. I don't see why what I want to do should be impossible. I think I can do it if I save the original readtable and access it before reverting and the closing parenthesis.
1:44:56
no-defun-allowed
if you want to do a readtable thing, #f[code goes here] could work better for syntax i think
1:53:42
didi
I never used a read macro, but luv-slides has one that I might try some day: #L(if (oddp _) (* _ _) 0) -> (lambda (_) (if (oddp _) (* _ _) 0))
2:39:07
didi
Argh. Format's call function directive is not too hot; I've to use colons to call functions from packages, even if it's a symbol interned in the same package I'm in.
2:49:49
aeth
Any list/cons processing should directly or indirectly use destructuring-bind unless there's a built-in to handle it directly imo. Probably slows it down a bit but makes sure it is what you think it is.
2:51:09
aeth
(and if you actually don't care about the tail in a destructuring-bind it's not hard to do an ignored &rest rest)
2:52:59
aeth
In this particular case, most alternatives would probably work on NIL because (car nil) is NIL and (cdr nil) is NIL.
4:35:56
fiddlerwoaroof
elderK, equwal: LoL is a bit problematic because it doesn't restrict its macro definitions to things that are standards-compliant.
4:36:19
fiddlerwoaroof
So, in some cases, you might discover that implementations have implemented things in a way that breaks the examples.
4:37:21
fiddlerwoaroof
But, I learned the useful trick of expanding to a MACROLET in situations where one might otherwise try to write a codewalker from it.
8:20:32
beach
IF you know what you are doing, IF you have extreme performance requirements, IF you know that your implementation generates faster code for structs, IF your application is know to spend a significant amount of time accessing object slots, and IF you are willing to live with the semantics of structs, then you should use them.
8:23:48
beach
Also, slot accessors for structs are ordinary functions, and if your implementation is slower on calling a generic function, that will make structs faster as well.
8:25:07
Inline
that all sounds like inviting into structs first, try out a few oop with structs and then later on try to switch onto clos....
8:25:10
beach
Now, like I said yesterday in #clschool, I often see people using structs for better performance, but then they are totally incompetent when it comes to designing efficient data structures and algorithms. It would be much better to do it the other way around.
8:25:35
beach
Inline: Why do you say that? I would think the other way around. Premature optimization and all.
8:26:12
beach
Structs really mess up the development process, so you would want them in the end, if at all.
8:26:57
another-user
beach: i have also implemented example you gave me(optimization without breaking interface) and i was really impressed!
8:27:07
no-defun-allowed
structs are basically the C structs, they're a bunch of values stuck together
8:27:58
no-defun-allowed
a standard-instance has superclasses, subclasses, and all the OOP stuff going for it
8:28:33
beach
Inline: By the way, you can't "switch into CLOS" because CLOS is already present. STRUCTURE-OBJECT and STRUCTURE-CLASS are perfectly good classes.
8:40:19
jcowan
Henry Baker very much preferred structures to classes (maybe still does, I don't know)
8:41:46
jackdaniel
structures conceptually are much simplier, I can imagine why he preferred them in his theoretical works
8:47:03
jackdaniel
I'm certain that everyone talking about classes in Common Lisp means standard-class (and not i.e builtin-class or a metaclass of some kind)
8:47:24
jackdaniel
s/everyone/everyone in above discussion/ I can imagine someone talking about clases in general of course
8:52:42
beach
Inline: So when you say "that all sounds like inviting into structs first", either you don't buy my advice, or else it means that you initially assume that you know what you are doing, that you have extreme performance requirements, that you know that your implementation generates faster code for structs, that your application will spend a significant amount of time accessing object slots, and that you are willing to live with the
8:53:49
pjb
well, one advantage of defstruct is that it's more concise than defclass. (defstruct pt x y) and you're set.
8:54:23
jackdaniel
nb: define-class in ergolib gives you similar concise syntax for standard classes
8:58:43
pjb
The only serious problem you may have with defstruct is that the readers and writers it generates are not (necessarily) generic functions.
9:00:36
no-defun-allowed
the #1 draw for defstruct for me is that it's less typing cause of the implicit accessors, which is really stupid come to think of it
9:01:28
pjb
But classes have so many advantages. You can use change-class, you can have multiple-inheritance, you can introspect the slots with the MOP, you can add slots at run-time…
9:02:14
pjb
But structs can use vector or lists are storage, and you still have inheriting with :include >:-}
9:02:39
jackdaniel
no-defun-allowed: while it is OK to be suspicious about macros which define functions on your behalf I don't know how this is stupid - could you elaborate?
9:03:07
no-defun-allowed
that the only reason to use defstruct early in development is that it's less typing
9:05:02
jackdaniel
that's why we abstract many things with new words: you say "computer", not "an electronical circuit with a program which …"
9:05:13
pjb
Anyways, in an application, you often will write special macros to define entities of your application, that expand into a defclass and more, so you won't have to write all the verbosity of defclass yourself anyways.
9:06:23
no-defun-allowed
yes, maybe a simpler macro that expanded to defclass would be more reasonably
9:11:12
beach
I submitted this idea in #sicl, but there was no reaction: What if the :TYPE option of a slot that mentions a class could result in a slot writer method that specialized on both its parameters?
9:13:01
pjb
Furthermoree, that doesn't prevent the existance of other writers with other classes for the value, so you won't get an error. Also you'd get a missing method error, instead of a type error.
9:13:21
no-defun-allowed
so if you had a :type of FOO in BAR for the slot BAZ it'd generate the equivalent of (defmethod bar-baz ((bar bar) (baz foo)))?
9:15:19
beach
no-defun-allowed: That's the idea, yes, except it would be (defmethod (setf BAZ) ((new-value FOO) (object BAR)) ...)
9:15:52
pjb
beach: actually, the point is that I feel uneasy with it, because I'm not sure there wouldn't be case where the semantics would change. We could know if we had a formal semantic definition of the language, and check the equations…
9:16:04
no-defun-allowed
i like it, sounds good, but i think a second one would also be needed to handle type-errors presumably
9:17:52
no-defun-allowed
strangely enough, both SBCL and CLISP allow me to create an instance of a class where the slot type requirement is violated
9:17:57
pjb
I may have written such setter method by hand, so I'm not entire against the idea. Perhaps it would enter into the generalization category, so it'd be acceptable. It would allow us to write additionnal methods for other classes of value.
9:18:53
no-defun-allowed
i did (defclass a () ((b :initarg :value :type integer))) and (make-instance 'a :value :foo) and it still made the instance
9:20:22
jackdaniel
no-defun-allowed: standard doesn't say, that implementation has to enforce such type, it is just an annotation
9:23:49
jackdaniel
so in that case bahavior will be different if you supply class name as a type and if you supply another type. I wonder how much it could bite a programmer
9:24:34
beach
Good question. That's why I submitted the idea here, so that people could help me think about it.
9:26:40
jackdaniel
I don't know how much code out there depends on type-error being signalled on such setf (given standard does not mandate such error)
9:27:08
jackdaniel
but if there is such code, then handling of such conditions will break inconsistently
9:27:10
pjb
Well, the first difference would be that you'd have a method more specialized than expected. So some program could have other methods, with a more general class, a more specific class or with the same class, that would override the defclass provided method.
9:28:20
pjb
You would need to still provide the method on T, so that user supplied method with a more general class could still call-next-method. They'd be shadowed by your method for values of the correct class, but not for values of superclasses.
9:29:13
pjb
So the question is how many program include such additionnal methods on writers, and whether we accept to break them, or whether we want to continue support the possibility even if it's (almost) never used.