[Python-Dev] Re: Words rather than sigils in Structural Pattern Matching

2020-11-23 Thread Baptiste Carvello
Hi, Le 23/11/2020 à 01:41, Greg Ewing a écrit : > On 23/11/20 7:49 am, Daniel Moisset wrote: >> Look at the following (non-pattern-matching) snippet: >> >>     event = datetime.date(x, month=y, day=z) > > The only names that are treated as lvalues there are to the left > of an '='. […] This is a

[Python-Dev] Re: Words rather than sigils in Structural Pattern Matching

2020-11-23 Thread Brian Coleman
Greg Ewing wrote: > On 23/11/20 7:49 am, Daniel Moisset wrote: > > Look at the following (non-pattern-matching) > > snippet: > > event = datetime.date(x, month=y, day=z) > > > > The only names that are treated as lvalues there are to the left > of an '='. The rules are a lot simpler. > One of the

[Python-Dev] Re: Words rather than sigils in Structural Pattern Matching

2020-11-22 Thread Greg Ewing
On 23/11/20 7:49 am, Daniel Moisset wrote: Look at the following (non-pattern-matching) snippet: event = datetime.date(x, month=y, day=z) The only names that are treated as lvalues there are to the left of an '='. The rules are a lot simpler. One of the Zen lines says "If it's hard to

[Python-Dev] Re: Words rather than sigils in Structural Pattern Matching

2020-11-22 Thread Daniel Moisset
On Sun, 22 Nov 2020 at 00:31, Greg Ewing wrote: > On 22/11/20 6:47 am, David Mertz wrote: > > I'm convinced by Guido, > > Brandt, and others that the binding use will be far more common, so > > adding extra characters for the 90% case does not feel desirable > > Minimising the number of

[Python-Dev] Re: Words rather than sigils in Structural Pattern Matching

2020-11-22 Thread Marco Sulla
On Sun, 22 Nov 2020 at 01:27, Greg Ewing wrote: > That's a fairly complex bit of mental parsing to do > when reading a case. I agree, that's why I wrote pattern matching seems exotical to me. I was accustomed by Python to read the code as if it's wrote in simple English. I must admit this is not

[Python-Dev] Re: Words rather than sigils in Structural Pattern Matching

2020-11-21 Thread Greg Ewing
On 22/11/20 1:07 pm, Henk-Jaap Wagenaar wrote: On Sat, 21 Nov 2020 at 19:58, Glenn Linderman > wrote: Don't () already indicate an expression to be evaluated? Does it? [(a, b)] = [(0, 1)] Presumably a comma would be needed to match a 1-tuple. case

[Python-Dev] Re: Words rather than sigils in Structural Pattern Matching

2020-11-21 Thread Greg Ewing
On 22/11/20 6:47 am, David Mertz wrote: I'm convinced by Guido, Brandt, and others that the binding  use will be far more common, so adding extra characters for the 90% case does not feel desirable Minimising the number of characters is not the only consideration. Readability counts too, and

[Python-Dev] Re: Words rather than sigils in Structural Pattern Matching

2020-11-21 Thread Henk-Jaap Wagenaar
On Sat, 21 Nov 2020 at 19:58, Glenn Linderman wrote: > Don't () already indicate an expression to be evaluated? > Does it? [(a, b)] = [(0, 1)] print(a) gives 0 as output. ___ Python-Dev mailing list -- python-dev@python.org To unsubscribe send an

[Python-Dev] Re: Words rather than sigils in Structural Pattern Matching

2020-11-21 Thread Marco Sulla
On Sat, 21 Nov 2020 at 18:52, David Mertz wrote: > So in my mind, if I had the choice, it is a decision between a sigil and a > word > to indicate "no, really use this name as a value!" I like a word better, but > none > of the current keywords really make sense, so it would need to be a new

[Python-Dev] Re: Words rather than sigils in Structural Pattern Matching

2020-11-21 Thread Glenn Linderman
On 11/21/2020 9:47 AM, David Mertz wrote: So in my mind, if I had the choice, it is a decision between a sigil and a word to indicate "no, really use this name as a value!" I like a word better, but none of the current keywords really make sense, so it would need to be a new word. I suggested

[Python-Dev] Re: Words rather than sigils in Structural Pattern Matching

2020-11-21 Thread David Mertz
On Sat, Nov 21, 2020 at 2:47 PM Guido van Rossum wrote: > On Sat, Nov 21, 2020 at 9:52 AM David Mertz wrote: > >> So in my mind, if I had the choice, it is a decision between a sigil and >> a word to indicate "no, really use this name as a value!" I like a word >> better, but none of the

[Python-Dev] Re: Words rather than sigils in Structural Pattern Matching

2020-11-21 Thread Guido van Rossum
On Sat, Nov 21, 2020 at 9:52 AM David Mertz wrote: > So in my mind, if I had the choice, it is a decision between a sigil and a > word to indicate "no, really use this name as a value!" I like a word > better, but none of the current keywords really make sense, so it would > need to be a new

[Python-Dev] Re: Words rather than sigils in Structural Pattern Matching

2020-11-21 Thread David Mertz
I'm not sure it matters in all the threads. But my underlying opinion is that we SHOULD have a mechanism to use a plain name (that has an assigned value in the scope) as a value in match patterns, not only as binding targets. However, in contrast to Nick Coghlan, I do not think access should be

[Python-Dev] Re: Words rather than sigils in Structural Pattern Matching

2020-11-17 Thread Alan G. Isaac
In Mathematica, you might do this as (roughly): rules = { {x_, y_, z_} :> {x, y, z}, {x_, y_} :> {x, y, 0.0}, x_ :> {x, 0.0, 0.0} } process[Replace[obj, rules]] Whatever you think of the particular syntax: The ability to declare resuable rules seems good. Thinking of replacement

[Python-Dev] Re: Words rather than sigils in Structural Pattern Matching

2020-11-17 Thread Steven D'Aprano
On Tue, Nov 17, 2020 at 08:49:28AM +0100, Marco Sulla wrote: > PS: pattern matching, for a mere mortal like me, seems to be something very > exotical. Have you ever written code that looks like this? if isinstance(obj, tuple) and len(obj) ==3: x, y, z = obj elif isinstance(obj,

[Python-Dev] Re: Words rather than sigils in Structural Pattern Matching

2020-11-16 Thread Marco Sulla
On Tue, 17 Nov 2020 at 03:52, Steven D'Aprano wrote: > Here is a more representative example, borrowed from here: > > https://gvanrossum.github.io//docs/PyPatternMatching.pdf > > > match node: > case BinOp(Num(left), '+', Num(right)): > return Num(left + right) >

[Python-Dev] Re: Words rather than sigils in Structural Pattern Matching

2020-11-16 Thread Steven D'Aprano
On Sat, Nov 14, 2020 at 11:11:37PM +1000, Nick Coghlan wrote: > On Fri, 13 Nov 2020 at 09:39, David Mertz wrote: > > > > I have read a great deal of discussion on the pattern matching PEPs and > > less formal discussions. It is possible I have overlooked some post in all > > of that, of

[Python-Dev] Re: Words rather than sigils in Structural Pattern Matching

2020-11-14 Thread Christian Nielsen
I very much second this opinion /Christian On Sat, 14 Nov 2020, 15.16 Joao S. O. Bueno, wrote: > > > On Sat, 14 Nov 2020 at 10:16, Nick Coghlan wrote: > >> On Fri, 13 Nov 2020 at 09:39, David Mertz wrote: >> > >> > I have read a great deal of discussion on the pattern matching PEPs and >>

[Python-Dev] Re: Words rather than sigils in Structural Pattern Matching

2020-11-14 Thread Joao S. O. Bueno
On Sat, 14 Nov 2020 at 10:16, Nick Coghlan wrote: > On Fri, 13 Nov 2020 at 09:39, David Mertz wrote: > > > > I have read a great deal of discussion on the pattern matching PEPs and > less formal discussions. It is possible I have overlooked some post in all > of that, of course. > > > > ...

[Python-Dev] Re: Words rather than sigils in Structural Pattern Matching

2020-11-14 Thread Nick Coghlan
On Fri, 13 Nov 2020 at 09:39, David Mertz wrote: > > I have read a great deal of discussion on the pattern matching PEPs and less > formal discussions. It is possible I have overlooked some post in all of > that, of course. > > ... OK, just saw Guido's "wait for new SC" comment, which I

[Python-Dev] Re: Words rather than sigils in Structural Pattern Matching

2020-11-14 Thread Paul Sokolovsky
Hello, On Thu, 12 Nov 2020 19:38:38 -0400 David Mertz wrote: [] > One idea that I cannot recall seeing, but that seems to make sense to > me and fit with Python's feel is using a WORD to distinguish between a > variable value and a binding target. That is, instead of a special > case

[Python-Dev] Re: Words rather than sigils in Structural Pattern Matching

2020-11-13 Thread Luciano Ramalho
On Thu, Nov 12, 2020 at 8:41 PM David Mertz wrote: > One idea that I cannot recall seeing, but that seems to make sense to me and > fit with Python's feel is using a WORD to distinguish between a variable > value and a binding target. That is, instead of a special symbol prefixing > or