On Wed, Oct 23, 2019 at 5:30 AM Steven D'Aprano <st...@pearwood.info> wrote:
> On Tue, Oct 22, 2019 at 08:53:53PM -0400, Todd wrote: > > [I wrote this] > > > I would expect %w{ ... } to return a set, not a list: > > > > > > %w[ ... ] # list > > > %w{ ... ] # set > > > %w( ... ) # tuple > > > > > [Todd replied] > > This is growing into an entire new group of constructors for a very, very > > limited number of operations that have been privileged for some reason. > > Sure. That's what syntactic sugar is: privileging one particular thing > over another. That's why, for example, we privilage the idiom: > > import spam > eggs = spam.eggs > > by giving it special syntax, but not > > class Spam: ... > spam = Spam(args) > del Spam > > Some things are privileged. We privilage for-loops as comprehensions, > but not while-loop; we privilage getting a bunch of indexes in a > sequence as a slice ``sequence[start:end]`` but not getting a bunch of > items from a dict. Not everything can be syntactic sugar; but that > doesn't mean nothing should be syntactic sugar. > This is getting bogged down in details. Let me explain as simply as I can why I don't think this is a good idea. Everyone has a different set of things they want privileged with a new syntax. Everyone has different things they consider to be "annoyances" that they wish took less characters to do. And everyone who wants a new syntax thinks that new syntax should the "one way" of doing that operation. If we accepted every syntax everyone wants the language would be unusable. We have to draw the line somewhere. For any new syntax I can think of, it significantly simplified real use-cases, was more expressive in some way, or made things more consistent. This, on the other hand, does none of these. Getting a performance benefit doesn't require a new syntax. So the only benefit this has is saving a few characters once per operation, at the expense of being less flexible. And again, if we made a new syntax every time someone wanted to save a few characters the language would be unusable. So I just don't think this reaches what is my understanding of the bar new syntax has to reach.
_______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/3SI4MAL5IOHXOAK2NROVQP2U4JKWEPAM/ Code of Conduct: http://python.org/psf/codeofconduct/