<_whitenotifier-3>
[amaranth-lang/amaranth-lang.github.io] github-merge-queue[bot] eaf4a91 - Deploying to main from @ amaranth-lang/amaranth@82d35fb93243aa8bdc50bf13be0f4cba472d037d 🚀
crzwdjk has quit [Ping timeout: 260 seconds]
richardeoin has quit [Ping timeout: 256 seconds]
richardeoin has joined #amaranth-lang
mindw0rk has quit [Read error: Connection reset by peer]
Degi_ has joined #amaranth-lang
Degi has quit [Ping timeout: 268 seconds]
Degi_ is now known as Degi
RobTaylor[m] has joined #amaranth-lang
<RobTaylor[m]>
<crzwdjk> "An RFC for fancier pattern..." <- As in parsing in hardware?
iposthuman[m] has quit [Quit: Idle timeout reached: 172800s]
jjsuperpower has quit [Ping timeout: 240 seconds]
frgo has joined #amaranth-lang
frgo has quit [Remote host closed the connection]
frgo has joined #amaranth-lang
frgo has quit [Ping timeout: 276 seconds]
frgo has joined #amaranth-lang
frgo has quit [Ping timeout: 264 seconds]
nelgau has quit [Ping timeout: 260 seconds]
nelgau has joined #amaranth-lang
frgo has joined #amaranth-lang
frgo has quit [Ping timeout: 268 seconds]
sickos has joined #amaranth-lang
nelgau has quit [Ping timeout: 252 seconds]
frgo has joined #amaranth-lang
nelgau has joined #amaranth-lang
frgo has quit [Ping timeout: 264 seconds]
frgo has joined #amaranth-lang
nelgau has quit [Read error: Connection reset by peer]
<ravenslofty[m]>
designing things at a high level is tricky for me; my brain doesn't like it. *sigh*
<ravenslofty[m]>
anyway: let's take the vague concept of "fancier pattern matching" and call it "pattern captures" for now. suppose somebody uses multiple pattern captures in an `m.Case` and these patterns overlap in such a way that you could end up with multiple simultaneous matches. this is presently fine in the existing semantics (it's still a match) but under pattern captures this might be ambiguous
<ravenslofty[m]>
does this imply that it should not replace the existing semantics and instead go into a library?
<whitequark[cis]>
can you explain what the ambiguity is?
<whitequark[cis]>
Switch/Case run on a "first match wins" basis; you don't get exhaustiveness checks (too expensive)
<ravenslofty[m]>
`m.Case('00nn', 'nnnn')` or something like that; a mistake from the programmer (we presume)
<ravenslofty[m]>
(this also has another thing I've been thinking about, which is: what's the shape of `n` here?)
<whitequark[cis]>
<ravenslofty[m]> "(this also has another thing I'..." <- I think having `nn` and `nnnn` in one `Case` or `matches` should be an error (different lengths)
<whitequark[cis]>
however if you had something like m.Case('0000 nnnn', '1100 nnnn'): should be allowed (why not?)
<ravenslofty[m]>
I don't consider that ambiguous and would agree that it should be allowed
<ravenslofty[m]>
`m.Case('0001 nnnn', '000- nnnn')` *is* ambiguous given `0001 ----`
<whitequark[cis]>
we already allow m.Case('0001 0000', '000- 0000') though
<whitequark[cis]>
so nnnn adds no new ambiguity
<whitequark[cis]>
you could say that m.Case('0001 nnnn', 'nnnn 0000'): has a worse ambiguity
<ravenslofty[m]>
sure, and that's the kind of thing I'm talking about
<galibert[m]>
well, "first in the list wins" is an easy rule, much easier than trying to sort out whether they match each other
<ravenslofty[m]>
and `m.Case('0001 ----', '---- 0000')` isn't an issue
<ravenslofty[m]>
I disagree, Olivier, I consider this to be a usability problem and usability problems are bugs, AIUI
<galibert[m]>
Ok, then explain to be in small words why 0001 ---- / ---- 0000 is not an issue while 0001 nnnn / nnnn 0000 is?
<galibert[m]>
s/be/me/
<ravenslofty[m]>
because `0001 ----`/`---- 0000` returns a boolean with relatively clear semantics (it's an OR of all patterns) that does not care about bit position and `0001 nnnn`/`nnnn 0000` *does* care about bit position
<ravenslofty[m]>
but honestly? yes, you could absolutely make the point that the multiple overlaps is potentially a sign of a bug
<galibert[m]>
python short-circuits or, so I don't find it ambiguous
<whitequark[cis]>
<ravenslofty[m]> "sure, and that's the kind of..." <- what I'm saying here is that this should probably not be in scope for the RFC you're writing, since it's existing behavior
<whitequark[cis]>
I'm completely open to discussing two RFCs, one that adds captures and one that resolves this ambiguity
<ravenslofty[m]>
Okay, I guess I'll just throw this in future possibilities
<ravenslofty[m]>
I feel like my relatively limited knowledge of "advanced python"™️ hinders me a bit when trying to design things
<ravenslofty[m]>
like, I'm designing this with some underlying assumption that somebody Better Than I will know the right way to do it
crzwdjk has joined #amaranth-lang
<crzwdjk>
RobTaylor[m]: Yes, parsing in hardware, in my case of terminal escape codes.
smkz has joined #amaranth-lang
jjsuperpower has joined #amaranth-lang
cr1901 has quit [Read error: Connection reset by peer]
cr1901 has joined #amaranth-lang
pbsds has quit [Quit: Ping timeout (120 seconds)]
pbsds has joined #amaranth-lang
key2 has quit [Ping timeout: 245 seconds]
key2 has joined #amaranth-lang
_alice has quit [Read error: Connection reset by peer]
LoveMHz has quit [Read error: Connection reset by peer]
esden has quit [Read error: Connection reset by peer]
_alice has joined #amaranth-lang
LoveMHz has joined #amaranth-lang
esden has joined #amaranth-lang
sugarbeet has quit [Ping timeout: 245 seconds]
sugarbeet has joined #amaranth-lang
jjsuperpower has quit [Remote host closed the connection]