Words rather than sigils in Structural Pattern Matching
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 suppose applies to this too :-). 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 suffixing a name, either to indicate it is or is not a binding target. Of course, whether the extra word would be used for binding or for NOT binding is a question still. NOT_FOUND = 404 match http_code: case 200: print("OK document") case value NOT_FOUND: # use the variable value print("Document not found") case OTHER_CODE: # bind this name print("Other HTTP code", OTHER_CODE) Of course, this would require a soft keyword, which is a disadvantage. Going the other direction: NOT_FOUND = 404 match http_code: case 200: print("OK document") case NOT_FOUND: # use the variable value print("Document not found") case bind OTHER_CODE: # bind this name print("Other HTTP code") To me these read better than the punctuation characters. But I guess some folks have suggested enlisting 'as', which is a word, of course. -- Keeping medicines from the bloodstreams of the sick; food from the bellies of the hungry; books from the hands of the uneducated; technology from the underdeveloped; and putting advocates of freedom in prisons. Intellectual property is to the 21st century what the slave trade was to the 16th.
participants (16)
-
Alan G. Isaac
-
Baptiste Carvello
-
Brian Coleman
-
Christian Nielsen
-
Daniel Moisset
-
David Mertz
-
Glenn Linderman
-
Greg Ewing
-
Guido van Rossum
-
Henk-Jaap Wagenaar
-
Joao S. O. Bueno
-
Luciano Ramalho
-
Marco Sulla
-
Nick Coghlan
-
Paul Sokolovsky
-
Steven D'Aprano