-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Turn the prompter function slots into methods? #29
Comments
Alternatively, we could have the
(closer-mop:ensure-method
#'constructor
'(lambda (source)
(log:info "My specialization")
`(a ,@(call-next-method) c))
:specializers (list (closer-mop:intern-eql-specializer my-source)))
This would allow us to benefit from the full power of CLOS (note (prompt
:prompt "Reduce buffer(s)"
:sources (make-instance 'buffer-source
:constructor '(lambda (source)
(log:info "My specialization")
'(a b c))
:return-actions '(identity)
:multi-selection-p t)) |
Your second suggestion seems quite elegant. Even though honestly I don't quite follow everything that would be happening (I need to study CLOS again). |
Now that I know But I believe it would be risky to push such changes on the eve of a new big release. |
This would definitely be part of the Big Prompter Refactor. Whether we can make for 3.0 is another question... Let's see. |
Alternative solution for Look at this elegance. Slot definition: (constructor #'some-lambda :accessor t) and then an (defmethod constructor :around ((arg prompter-class))
(let ((result (call-next-method)))
(etypecase result
(function (funcall result arg))
(list result)))) Given that
Neat, huh? This retains the slot, but preserves both method specialization per source CLOS-style (if one needs it), and the old-fashioned initarg&lambda one! Not sure how this applies to other slots, but at least EDIT: More clarifications and a call to implementation :) |
I anticipate that there will be some polishing after the Big Prompter Refactor. Such changes often require some time for the dust to settle. I've put some effort in stabilizing the current implementation of the prompt buffer from a functional point of view and documentation-wise. Also, I don't think that the Big Prompter Refactor will radically change the user experience. It will improve it, but it won't be a complete novel experience. For these reasons, I think we should assign the task for post 3.0 so that there's enough time to mature the changes (in between two major releases, 3.0 and 4.0). |
One thing that I'd change before 3.0 is |
I'm not convinced about that design. I think @Ambrevar did it the way it is now for a good reason, namely performance. One thing that should be fixed is the fact that these offsets aren't sanity checked (for instance, whether they're within bounds). |
I think that this comment in our
In other words, only optimize it if it's actually a bottleneck :) The design with list search is not perfect either, but it works well enough in REPL, for instance. I see no reason (except performance, which has to be proven) to exchange it for opaque indices instead of the nice'n'shiny CLOS objects and search for these :D Even if there would be a performance problem, we can solve it by using vectors over lists (probably some 3x speedup on really big data) or by somehow memoizing/indexing data. So introducing C-style primitives like offsets should be the last resort :) |
While this specific part of the API can be deferred to 4.0, some other prompt buffer issues are more critical, like the freeze when you type to fast... :( EDIT: To fix this freeze, I suspect we might have to switch to Lparallel, which would require a significant overhaul. |
Indeed, if such critical issues are found, then they are a goal for 3.0. But I can't reproduce this bug. Is there an issue about it or a specific recipe? |
Prompters have a bunch of slots which are meant to be functions.
prompt
class:constructor
before-destructor
after-destructor
source
class:constructor
destructor
suggestion-maker
filter
filter-preprocessor
filter-postprocessor
resumer
There are also
actions
andselection-actions
but, since it's a list of functions, methods would not do here.Generic functions have many benefits over standard functions, but I can think of one drawback: Typically they are defined globally and methods must be specialized on classes, not objects.
We often have a use case like this:
Here it's convenient that we do not have to define a source only for the purpose of specializing the constructor.
Suggestion: go with generic functions but keep the
constructor
and*-destructor
slots for local overrides.Thoughts?
The text was updated successfully, but these errors were encountered: