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 the
default, but that binding should be.  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, even if it is arguably
more consistent with other elements of the language.

The second example I give of binding requiring the extra syntax was for
completeness, but I would not support it myself.  If binding were to
require extra syntax, I think Nick's 'as' suggestion is better than my
prefix word idea (if only because it doesn't need a new soft keyword).  I
do not think the answer of "put the plain name into an enumeration or other
object so it can be accessed as a dotted name" is quite enough.  Yes,
that's possible, but it feels more forced.

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 "value", but another word might be
better.

On Thu, Nov 12, 2020 at 7:38 PM David Mertz <me...@gnosis.cx> 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 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.
>


-- 
The dead increasingly dominate and strangle both the living and the
not-yet born.  Vampiric capital and undead corporate persons abuse
the lives and control the thoughts of homo faber. Ideas, once born,
become abortifacients against new conceptions.
_______________________________________________
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/python-dev@python.org/message/WAGBJUKGS5V7AGUYDWNZAI5NNA76MXYN/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to