@dominicm Whats flagged unused?
@noprompt For something like:
{:a ?a :b ?b} (+ ?b 10)
?a would be unused, but you're using it to ensure :a is present… Although maybe I'm doing it wrong :){:a (m/some) :b ?b} (+ ?b 10)
@noprompt Ah, so maybe my hack is sufficient then. If I get some energy I'll play around with it.
Oh, hmm, that's not the same?
{:a nil}
should match {:a ?a}
It’ll also match {:no-a here}
Going back and forth here on the most delicate way to express this but, eh, I can’t tactfully say it better: that macroexpand idea is a mixed bag.
It's a difficult set of constraints to balance. I'm thinking that core.match and meander are probably the major use-cases for it.
I stopped using clj-kondo because of all the complaints about variables it didn’t understand in macros.
IMHO some kind of symbolic execution would probably be the best.
But its a lot of work.
yeah, it is. I do wonder if sci could just run meander tbh.
I was thinking that too.
matchete might make a good candidate also.
I made a thing for code search/replace about a year ago but I never made it into a solid stand alone thing.
Ultimately, whatever we would implement only need be "good enough" that 99% of my annoyances with meander linting go away :)
let me know if you figure it out, clojure-lsp has to keep expanding it's macro-defs for handling the problem 😞
We could export an interpreter pretty easily.
Its been an outstanding issue for a while.
@snoe I’m putting a sticky on my monitor to remind me to get familiar with clojure-lsp this week.
@dominicm Seems like clj-kondo would have an off switch.
For specific forms.
Linters. 💣
@noprompt you can, yeah. But it's nice to get some feedback within those forms. Consider my try+, I'd have to disable linting in the whole try+ macro, so it wouldn't catch this:
(try+
(let [x] …))
To clarify, kondo already has the off-switch for specific forms :)
This is one of the reasons I like the idea of “notation” over macros.
Because with notation its simply a symbolic transformation.
notation?
Macros can have arbitrary code run which is super powerful but comes at the expense of increased analysis difficulty.
Right
defsyntax
has this problem.
I wanted to add defnotation
which would basically be a symbolic rewrite rule instead of one that executes code.
The advantage is that there is no code which can interfere with determining the shape of data coming out of the transform.
At the cost of the power to manipulate strings and do many evil things therein. 😛
Here’s the delta interpreter: https://gist.github.com/noprompt/085d100de4e85d7b643e438498e08b56
Basically, you would parse
the form and then interpret the match.
zeta
kinda works both ways where the macro compiler uses the interpreter API when it as to and more advanced compilation moves when it can.
Not at keyboard, but would {:a _}
be the right form?
epsilon
probably should have been designed this way from the start but I started at “make a pattern matcher like core match that I maintain”
No, you have to use m/some
.
With the ability to configure the compiler/parser/etc soon we can indicate that a map is strict.
But m/some wouldn't match a nil value. That makes the behavior different.
The decision to place the constraint on value is 99% due to the fact there is no operational/observable difference between (get {} :a)
and (get {:a nil} :a)
.
Yeah…
That’s the screwed up thing.
(get {:a nil} :a :default)
This is why I like the pattern
(if-some [[_ value] (find m :a)]
,,,)
Yeah, I sometimes use that too :)
I try to be conscious of allowing nil
Right. It was a decision I made early on. The tradeoff of matching on the result of get
is this situation.
But if you have strict map matching with find
it can get really annoying.
Maybe something like
^:strict {:a nil}
BTW, if folks have any thoughts/ideas for flags share them on this PR: https://github.com/noprompt/meander/pull/124
My primary goal for this patch at the moment is to be able to completely move any AST manipulation out of the matrix compiler and into the match syntax namespace and then have flags to turn them on/off
I just realized we were talking past each other. https://cljdoc.org/d/meander/epsilon/0.0.421/doc/operator-overview#logic-variables title is optional in this example. I thought it was required.