Closed aartaka closed 1 year ago
Hmmmmmm, it seems to break because progn
combination has no primary methods 0_o That I didn't know. Maybe write our own combination then?
That's an option, I suppose. Then we can support :before
and :after
.
But can you give an example how progn
would be better here?
That's an option, I suppose. Then we can support
:before
and:after
.
But we don't really need them ( ͡° ͜ʖ ͡°) Maybe to concat to the beginning/end of the thing, but that's achievable with :around
...
I guess our own combination with prefixing and suffixing the list and with primary method would work better after all.
But can you give an example how
progn
would be better here?
It'd be better in appending attributes from several inherited sources/objects. The main application, as I've said, is Nyxt's hint-mode
.
Oh, wait, it should be append
instead of progn
(@´_`@)
I see it's useful for hint-mode, but is it so common that we want to reuse all the attributes of a parent? Seems a bit specific to me.
The problem with an append
method is that we don't control the attribute order much.
Note: maybe the loop
in the hint-mode example is needlessly complicated. Does it do the same as this?
(let ((attributes '(("URL" "http://foo.org"))))
(mapcar (lambda (attr)
(or (assoc attr attributes :test 'string=)
(list attr "")))
'("URL" "Body")))
Note: maybe the
loop
in the hint-mode example is needlessly complicated. Does it do the same as this?(let ((attributes '(("URL" "http://foo.org")))) (mapcar (lambda (attr) (or (assoc attr attributes :test 'string=) (list attr ""))) '("URL" "Body")))
No, it's merely ensuring the attribute is there. But I'm guessing we can simplify it too if we have a reasonable method combination.
It's our frequent use-case to compose
prompter:object-attributes
(as in Nyxt hint-mode). Which tends to be ugly and not-exactly-composable after all—adding:around
methods everywhere is quite a crude way to do things.progn
method combination seems to be a better shot—progn
methods are not limited in number (if the specifies differ), while being perfectly composable. The downsides exist, though::before
/:after
methods—only primary,progn
, and:around
. This doesn't exactly matter, because these barely matter forprompter:object-attributes
—it's a pure function not needing any watchers, after all.prompter:source
might end up polluting lots of sources. But that's avoidable too—just useprogn
methods sparingly.Mostly backwards-compatible too—I have no idea why anyone would use
:before
/:after
methods in their prompts, so that shouldn't break anything.EDIT: formatting, typos, and details