freenode/#lisp - IRC Chatlog
Search
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
22:49:49
Bike
putting in an (and keyword ...) won't speed anything up if the implementation doesn't simplify types somehow, and if it doesn't simplify types somehow type tests are probably going to be slow regardless
22:50:25
Bike
also even assuming the keyword type is checked first, for a member of the type it'll have to check a member anyway, so you'd just be speeding up testing on nonmebers at the expense of testing on members
23:02:17
Bike
on sbcl it has no effect on typep speed that i can see, because it reduces (and keyword (member ...)) to (member ...) if all the objects are keywords
23:12:47
Alfr_
Isn't it possible to reduce every (and type-spec (member ..)) to (member ..) simply by only retaining the objects o which satisfy (typep o type-spec)? Or am I missing something here?
23:24:59
aeth
Alfr_: Also, I think that technically every type can become a MEMBER type because everything's finite...
23:52:00
Bike
and any class you can make fresh instances of, so standard objects, hash tables, restarts, whatever
2:00:59
edgar-rft
It's always good to learn new things, but I myself never learned iter, so I don't know if it's really good to listen to my advice here.
6:52:17
holycow
anyone here use stumpwm? i'm doing a big of testing in emacs and drawing with code using sketch.
6:53:08
holycow
every time sketch draws something new it steals the window focus. anyone know if there is a way to stop the sketch window from setaling focus when emacs sends a live command to draw something to the sketch window?
7:25:21
opcode
hi all, newbie question: is there a reason why one might prefer (mapcar) over (map 'list ) or vice-versa?
7:29:31
beach
opcode: There is a very general rule in programming. You should choose the most specific construct that will do the job.
7:30:29
beach
The rule exists to make it faster to understand the code by someone who didn't write it, or by the same person who wrote it, but a few weeks later.
7:31:47
aeth
If you expect lists, use mapcar. If you are writing a general function on arbitrary input, map 'list might be preferable.