freenode/#lisp - IRC Chatlog
Search
15:57:48
jmercouris
I want to make it so that when someone defines a mode, they can execute a form that sets default keybindings for that mode
15:58:07
jmercouris
the keybindings are stored in a global hashmap with the same name as the class, just surrounded by earmuffs
15:58:28
jmercouris
why global hashmap? so that when you change a keybinding in that hashmap, it'll change in all running modes on all buffers
15:58:43
makomo
can't you write a macro that expands into (progn (defclass ...) <keybind-registration-forms>)?
15:59:08
jmercouris
makomo: I could, I thought about that, was just wondering maybe there is something better than that
15:59:24
jmercouris
maybe I should actually have something like (defmode ...) could be nice at any rate
15:59:54
makomo
i would say that would be a neater option as you're relying on standardized stuff (standardized meaning "in the CLHS")
16:01:02
makomo
well i was just thinking that it would be nice to abstract away the fact that modes are classes underneath
16:02:01
makomo
but, even if you do abstract away the fact that a mode is just a class, you don't have to turn it into a "black box" thing
16:02:27
makomo
i.e. the modes would still be "transparently specified" -- you would say "modes are indeed CLOS classes and have X as their superclass"
16:02:52
makomo
rather than "use *ONLY* DEFINE-MODE as i might change the representation of modes later on"
16:04:00
makomo
now, i don't think there's a general way of deciding whether or not one should define something transparently or not. it's mostly about creativity/gut feeling i would say :-)
16:04:33
ogamita
jmercouris: notice since defclass is a macro, you can play tricks with *macroexpand-hook*.
16:04:47
shka_
jmercouris: i think that you are better of using :allocation :class for your shorcuts
16:05:36
ogamita
jmercouris: but in your case, you should not let your users use defclass to define modes! Provide them with a define-mode macro, and do whatever you want!
16:06:56
ogamita
jmercouris: note also another example: CLIM defines its own defclass and defmethod macros, shadowing CL's ones, and when you want to use CLIM, you (:use "CLIM-CL") instead of (:use "CL").
16:07:27
ogamita
jmercouris: but since you're just defining modes, not generic classes in a GUI environment or something, define-mode is better.
16:10:39
jackdaniel
i.e some people are interested in seeing kerning included in McCLIM master branch
16:13:58
ogamita
makomo: just showing a derivation of the rules to expand ,@,@ would be enough proof.
16:19:44
jmercouris
here's the macro I came up with: https://gist.github.com/jmercouris/c8f5738ac6ac9ea3c4132edba73527f6
16:22:17
shka_
jmercouris: simply add base class for all nodes, add slot for this map, and during set default-initarg for it to your *map*
16:23:44
jmercouris
if you can't see anything hugely egregious with my macro, I think I will use it instead
16:25:07
jmercouris
I was thinking about putting it in another body for deferred execution until run time or something
16:25:50
makomo
jmercouris: then you can wrap the body within a lambda, store the lambda somewhere and call it later
16:26:28
jmercouris
makomo: I'll wrap it within a lambda, register it in a list, and then execute on startup, that makes the most sense
16:26:46
makomo
jmercouris: yeah, as ogamita says, the macro is pretty bare-bones right now, providing almost no abstraction over defclass
16:27:23
makomo
still though, using it anyway just to give a name to a concept ("defining a mode") is ok imo, even if the macro is trivial
16:27:27
shka_
i still think that managing shared setting for all instances of modes should be somehow placed into the class itself
16:27:49
kuwze
hey does anyone know what mocl is based on? I thought it was ecl but it can't be considering ecl is lgpl and won't allow for distributing bundled binaries (which is what I believe mocl offers)
16:32:04
ogamita
kuwze: it felt like mocl could have been based on clicc, but I haven't seen its sources (they're available for $). It's possible it was written from scratch.
16:32:53
ogamita
Ie. you have a (large) static subset of CL that is translated to C, with a small runtime library.
16:36:00
ogamita
It would be worth it to take clicc and modernize it to make a free competitor to mocl (which is has a lot of bugs and is not much maintained).
17:18:31
jasom
luis: I know there are ones that generate html, and markdown is a superset of html, so technically, yes...
17:44:43
jasom
luis: maybe? There are so many document generators that it's hard to keep track; sabra did a comparison of them a couple years ago, and he notes that it's already out-of-date.
17:46:31
jasom
https://sites.google.com/site/sabraonthehill/lisp-document-generation-apps/lisp-generation-apps-v1 <-- has a "multipage" row in the summary table
18:16:49
makomo
jasom: thanks for the link, sabra has quite a few comparisons i see. i appreciate the effort
18:23:00
makomo
ogamita: how did you perform the conversion of CLICC's package name when you first imported the project?
18:23:25
makomo
was it just a basic search-and-replace and you had to eyeball every replacement to make sure you didn't break something, or did you use something more sophisticated?
18:50:59
another-user
hi, i would like to define a method which will be called when object has changed, like :after method for setf of spicific :accessor but for whole object
18:55:21
Bike
another-user: you could define a metaclass and then a method on (setf slot-value-using-class). reinitialize-instance might result in it running more than once, though.
19:24:18
jcowan
ACTION is reading the CL0+CLOS0 document with an eye to how it might be rewritten to describe ANSI CL.
19:25:03
another-user
how would you solve followin problem: i have class with tons of different slots and i would like to serialize and save data from slots to file on every change made to instance of such class
19:25:35
another-user
there is an option mentioned by Bike but i'm not sure it's a proper way of doing it
19:27:43
another-user
i could define "update" wrapper function which will pass its args to corresponding setfs and save data to file afterwards but that doesn't seem good
19:30:19
another-user
shka_: will changing how writers/accessors are auto-generated cause same problem with reinitialize-instance?
19:31:30
stacksmith
Good morning. Does anyone know why SBCL's logcount compiles a conditional? I get TEST BYTE PTR [#x5010010B], 1 with a JEQ to a call and POPCNT on NE...
19:32:05
another-user
shka_: that's great! could you please tell me where can i find documentation on how to change how writers/accessors are auto-generated?
19:34:56
stacksmith
I have it optimising to the max, and (truly-the as an unsigned byte, etc. I was hoping to eliminate a conditional and a memory access if possible...
19:36:56
stacksmith
I thought it may be testing to see if the instruction is available - but that should not be a runtime check...
19:41:27
sjl_
https://github.com/sbcl/sbcl/blob/082a3f8317e0820ffae222bd8cd3020fd4605ea9/src/assembly/x86-64/arith.lisp#L331-L337 is where that test is coming from
19:43:07
shka_
https://stackoverflow.com/questions/25078285/replacing-a-32-bit-loop-counter-with-64-bit-introduces-crazy-performance-deviati
19:47:20
stacksmith
in '*cpuid-fn-ecx*'... Shouldn't do it once? It is very unlikely that my CPU will upgrade itself to a new model while running a tight loop....
19:50:20
stacksmith
That is just wrong... There has to be a way to set things like that to not check, locally...
19:52:12
sjl_
If you've got some profiling that shows a significant portion of your time is being spent on that TEST instruction, maybe #sbcl could help figure out an alternative approach you could take.
19:53:31
sjl_
I'd be surprised if a single instruction that always branches the same way ends up being a performance bottleneck. Even *I* can make a branch predictor that does a good job when only one branch is ever taken, and I'm not all that smart.
19:53:48
stacksmith
sjl_: I will get to that at some point... It seems that there is a whole class of session-local constants like this... I am surprised I haven't come across it before.
19:55:16
stacksmith
sjl_: True, the branch prediction should take care of that, but there is an entire cache line of code here instead of a 5-byte instruction.
19:56:40
sjl_
Sure. Profile and make sure it's actually a bottleneck, then feel free to worry about it.
19:58:21
stacksmith
sjl_: If I were a betting man, I would bet it is not a bottleneck... It's just one of those things that bug me and irritates my obsessive-compulsive disorder. I really should stop looking at disassembly.
20:05:26
makomo
stacksmith: i was going to ask what kind of an application you're writing when such stuff is so important
20:05:45
makomo
but then you said you didn't profile yet, so i was wondering "who checks the disassembly for 'no reason'?" :P
20:09:06
stacksmith
makomo: I did not profile this particular version because it would require quite a bit of work to change all the other parts of the code. And my loop is assembled with a bunch of macros, so profiling to localize problematic instructions would take a little effort...
20:10:22
makomo
stacksmith: ah i see. interesting issue nonetheless. may i ask what the program is for?
20:11:15
sjl_
SBCL will annotate the disassembly with instruction-level counts, you just have to use profile-call-counts with the function.
20:20:30
stacksmith
makomo: The particular loop is for walking a transaction log and updating the state of a data structure, which gets slow for long stretches. Basically I need dispatch for a few really fast cases (that occur often ) inline, and am always looking for branch-free ways of doing things.
21:39:52
pjb
jackdaniel: if you say that ,@form is not a form, then you won't be able to process ,,,x either.
21:40:34
jackdaniel
See rule 9: If the backquote syntax is nested, the innermost backquoted form should be expanded first. This means that if several commas occur in a row, the leftmost one belongs to the innermost backquote.
21:40:46
pjb
jackdaniel: so don't be silly, accept that in that rule, form can be prefixed by one or more , or ,@ .
22:01:52
makomo
jackdaniel: thanks. the earliest i'll be able to get to it is wednesday afternoon. i'll let you know in any case when i'm done (but it might take a while as i'm in the middle of my midterms).
23:55:37
jcowan
I'm kind of surprised that (subtypep '(simple-vector 10) '(simple-vector 5)) doesn't return true.
23:59:26
sjl
(simple-vector 10) can't be a subtype of (simple-vector 5) because the set of all 10-element simple-vectors isn't a subset of the set of all 5-element simple-vectors
0:02:44
jcowan
What they have in common is that aref and (setf aref) that works on one will work on the other, but that's not enough for Liskov substitutability.
0:19:08
jasom
If there were a type "all simple vectors with at least 5 elements" then (simple-vector 10) would be a subtype of it
0:40:13
stacksmith
In SBCL, (incf-pointer *foo*) causes "doing SAP to pointer coercion (cost 14)"... Even when *foo* is a SAP... Does anyone have any ideas of how to fix it? (sb-sys::sap+ *foo* 1) seems to do the same.
1:04:06
stacksmith
I take it back. It is really strange, but SAP-to-pointer conversion note comes up - I think in all cases where the new SAP is stored...
1:09:59
stacksmith
so (setf *foo* ptr) is fine, but (setf *foo* (inc-pointer ptr 4)) is a problem. (type-of ptr) is SB-SYS:SYSTEM-AREA-POINTER; (type-of (inc-pointer ptr 4)) is also SB-SYS:SYSTEM-AREA-POINTER and I am a bit stumped.
1:30:27
jasom
PuercoPop: it's possible that some implementaions mapc will be faster since it takes a list, not a sequence.
1:46:12
PuercoPop
sjl: ah, mapc returns something? Then yeah map nil would be a better fit for this case (stumpwm::raise-top-windows)
2:13:57
sielicki
I've been working on a homework assignment tonight and I thought it might be a good opportunity to practice lisp.
2:14:55
sielicki
I rewrote the C-like code in there into lisp. The idea is that I want to write a lisp function that takes in an arbitrary function and makes it either pass by reference or pass by value.
2:15:48
sielicki
Okay, forget I said anything about homework. I'm already done with the assignment, the class has nothing to do with lisp, it's trivial to rewrite that c-like function with pointers to make it give the results.
2:16:41
sielicki
Just on the question of an arbitrary lisp function that makes another function pass by value or pass by reference, is this possible with creative usage of quoting? I feel like it is but I'm too new to lisp to understand it.
2:19:58
LdBeth
There's a historical reason that compiler technology was not advanced to handle call by name, so macro comes out to completly replace the use of NLAMBDA