freenode/#lisp - IRC Chatlog
Search
12:24:56
VincentVega
Hmm, why does closer-mop:slot-definition-writers accept only a direct-slot-definition as an argument? What if I have a derived class and want to see writers for an inherited slot?
12:28:25
jmercouris
I don't understand why it cannot find that which exists, do I hvae the repository wrong? the signature wrong?
12:29:09
jmercouris
VincentVega: perhaps you will have to go up the inheritance tree and query the object which has the slot itself
12:32:09
VincentVega
jmercouris: well, that could be a solution, but I am wondering what's the reason for this, because it's weird to see this work
12:32:12
VincentVega
(c2mop:slot-definition-writers (first (c2mop:class-direct-slots (find-class class-name))))
12:32:22
VincentVega
(c2mop:slot-definition-writers (first (c2mop:class-slots (find-class class-name))))
12:33:10
jmercouris
and that way when you change something in a inherited class it updates in its descendants
12:33:56
jmercouris
my other guess is that this behavior is due to an implementation detail of CLOS within most implementations
12:35:39
VincentVega
but walking up the inheritence tree won't give me the effective list of writers/readers of the derived class unless I manually merge and that's a bother
12:36:44
VincentVega
I am generating :before methods for writers of those slots which invalidate cache of other slots
12:38:34
jmercouris
maybe you could make an instance of an object and inspect that more easily than the classes
12:39:26
VincentVega
i don't think it would even have to be runtime w/ eval-when :compile-toplevel, right?
13:31:18
jmercouris
mfiano: that is what I am doing, but it is not exactly the most cooperative interface...
19:40:45
VincentVega
Guys, why does ,@expr doesn't want to compile here? https://pastebin.com/gqBLSd7N
19:47:06
Bike
have you tried writing out what you want without using backquote? maybe that would make it more obvious.
19:47:28
Bike
i think the problem is that commas refer to the most recent backquote, and `,@expr obviously doesn't make sense on its own.
19:49:14
VincentVega
I am writing a macro-writing macro and that's what I figured the problem distills to.
19:49:21
pranavats
VincentVega: Comma-at must occur within a sequence. What it does is that it splices a list into a sequence. When you write `,@expr there is nowhere to splice the value of expr.
19:50:49
VincentVega
Bike: well I would expect `(f ,`,@expr) to simplify to `(f ,@expr), there's a comma before the backtick
19:51:52
aeth
VincentVega: if you have to nest multiple `s, don't do it directly imo. Either use a FLET or write a separate DEFUN that you call from inside of the DEFMACRO (if the latter, it needs to be in another file or in an EVAL-WHEN, though)
19:54:24
pranavats
alandipert: I get the same error (not a well formed backquote expression) with the example you gave.
19:55:05
VincentVega
pranavats: ok, yes, that makes sense. But I wonder why `(f ,`,@expr) just wouldn't simplify to the working `(f ,@expr) _before_ splicing
19:59:45
Bike
i think you are confusing evaluation times. i mean, you can imagine (let ((x (foo))) `,@x) where foo is some function
20:01:19
pranavats
VincentVega: I don't know. That is one of the two restrictions on comma-at in On Lisp. One might look at their implementations though...
20:02:25
VincentVega
pranavats: I should probably reread that part. I am cool with an flet though, like aeth suggested, wouldn't look as hairy either.
20:12:22
brandflake11
Hey all, is there a special notation in lisp to include a list as one of the arguments of defun?
20:12:52
Xach
brandflake11: the lambda list is usually a list. and the name can be (setf <something>) for setf functions.
20:14:56
brandflake11
But, when I try to run the function, I get an error of the list included is not of type real
20:16:06
Xach
brandflake11: but did you mean you wanted to slurp up all the trailing arguments after the fourth into a list?
20:16:59
Xach
brandflake11: in a situation like this it would be helpful to see the code, and how you called the function, and the exact error you got when you called it
20:17:28
brandflake11
Xach: Okay, I didn't want to take advantage of the great help here, but I will put it on pastebin really quick!
20:17:48
Xach
how else are we to grow new lisp experts and dominate the world but through helping people understand things?
20:19:53
brandflake11
I define the function with defun, and when I run the second (events) function, it gives me the error of '(60 61 62) not being of type real
20:20:42
brandflake11
Xach: Process is like loop, but helps with realtime processing of midi and audio data.
20:21:30
Xach
If you wanted to loop once for each item in the list, it would be someting like "from i below (length note-list)"
20:22:04
Xach
but if you want to use an element and keep a counter, it would be (loop for i from 0 for note in note-list ...)
20:23:09
brandflake11
Xach: Do you have any recommendation of becoming an expert at the (loop) function? It's syntax really gets to me sometimes!
20:24:03
Xach
brandflake11: i usually stick to a small number of simple components and switch to something different when it gets very complex
20:25:44
brandflake11
Xach: For loop, I try to just make C++ loop equivalents, since I'm a bit familiar with that, but I always get tripped up with the loop syntax being so different to lisp's
20:26:32
Xach
I think that's something to outgrow as you understand how to think directly in terms of LOOP.
20:27:50
pranavats
brandflake11: There are other iteration constructs in CL, —iterate and Series, to name just two—which are more lispier.
20:36:42
aeth
brandflake11: LOOP's a bit weird because it accepts any package for its symbols, but that means that you can use keywords. So e.g. (loop :for i :from 0 :repeat 3 :do (print i))
20:37:34
aeth
It almost becomes like a plist. Almost. There are a few constructs where LOOP expects multiple keywords in a row, and OF-TYPE is optional for certain kinds of types (but only a few, so I always use the long form)
20:38:22
aeth
(And, of course, if it was really made up of plists, order wouldn't matter and you couldn't have duplicates.)
20:38:31
brandflake11
aeth: What do you mean by it accepts any package for its symbols? I'm not familiar with plist.
20:39:31
aeth
It's very natural and Lispy and shows up all of the time, e.g. keyword arguments are plist tails
20:40:16
aeth
brandflake11: By "accepts any package" I mean (loop repeat 3) and (loop :repeat 3) both work, it doesn't care about the package the symbol is in. Almost every other macro will care. Third party macros typically use keywords.
20:41:07
aeth
(loop your-package::repeat 3) also works, which is probably what LOOP is doing because CL:REPEAT isn't a symbol
20:48:49
brandflake11
aeth: I see. That was a lot for me, so I am going to save this for later to see if I can come back and understand this better later. :) It's cool that you can use keywords like that in loop, I may use that to make it clearer for me!
21:03:05
dbotton
I have been using a deftype of keywords for enums, but curious is there a better or more official way?
21:07:06
VincentVega
dbotton: an aside, but with serapeum you can have compile-time checks for those https://github.com/ruricolist/serapeum#example-enums
21:10:25
frodef
dbotton: right.. I probably don't quite understand the question, then. There's no more "official way" than (member ..), and I can't really think of anything more succinct.
21:12:15
frodef
dbotton: note that you don't have to name the type, unless it's being used "all over" I'd say that (member :ltr :rtl) is quite readable as it is.
21:46:26
dbotton
Is there a way to hint to slime/emacs that a certain deftype is the ideal parameter so auto complete would work for it?
21:46:33
aeth
dbotton: two kinds of enums... the enum equivalent in an idiomatic way are basically member types. The other kind of enum is a mapping of symbol->number, which can be done with e.g. a function with an ECASE of keyword->number. These are not mutually exclusive, of course, although the language won't check to make sure every branch in the ECASE is covered.
21:47:34
aeth
dbotton: I usually just do MEMBER types, but technically, the more correct way is probably '(and keyword (member ...)
21:48:21
aeth
If something's not a keyword, that will rule it out much faster, unless the implementation optimizes member types