Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
syntactic sugar
#1
so, Python has some syntactic sugar. if that, then why not other things, such as a case statement, or an until clause, or a do statement. what is the principle for these decisions?
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply
#2
(Sep-04-2018, 07:11 PM)Skaperen Wrote: what is the principle for these decisions?
There was long discussion about this topic for many year.
It's relative easy to solve all this without adding stuff to the language,so all suggestion was rejected.
PEP 3103 -- A Switch/Case Statement

Quote:Author: guido at python.org (Guido van Rossum)
Status: Rejected
Created: 25-Jun-2006
Why isn’t there a switch or case statement in Python?
PEP 275 -- Switching on Multiple Values
Reply
#3
(Sep-04-2018, 07:11 PM)Skaperen Wrote: if that, then why not other things, such as a case statement, or an until clause, or a do statement
Python's success story didn't happen by chance. It is the result of very careful decisions about what to include in the language and what to exclude from it. Guido van Rossum designed it like a great artist and that's why it worked. He may perhaps one day fork python to escape the pressure of other python developers. Then it will be Guido's Python versus Python. If this happens, I will immediately choose Guido's Python.
(Sep-04-2018, 07:11 PM)Skaperen Wrote: Python has some syntactic sugar
It's more than an understatement.
Reply
#4
oh, no doubt, good decisions were made,leading to great success. i'm trying to understand the basis for this. for example, the common argument for not adding all that other stuff is that what they do can still be done without them. but decorators are in the same boat. what decorators do can still be done without them. so why are they an exception where the other things are not? i want to understand why they get to be this way and other "features" do not.

part of why i want to understand this is examining my ideas for a language that is so much like python. i want to think through if it could have been a success had it been designed earlier. completed, and released.
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply
#5
GvR's answer about the do-while.
Quote:Please reject the PEP. More variations along these lines won't make the
language more elegant or easier to learn. They'd just save a few hasty
folks some typing while making others who have to read/maintain their code
wonder what it means.
Reply
#6
so i don't understand why python has the @ form of decorators (the syntactic sugar) given that it can be done in a more basic way without that syntactic sugar ... plus the tendancy of python design to avoid syntactic sugar ... why this and not those?

did Guido lose control back then? just recently? if Guido makes a fork, you are going to follow his? i can understand wanting to follow his genius. would that be the reason,no matter what he does? if he didn't have the power to reject the PEP on his own, then he wasn't in control (nobody was, individually).

i would not wonder what do-while means. but i can see where it would add to the timeline of learning the language or learning programming for the first time. but decorators do that, too.

i still don't understand what @sc does. i can't consider doing it without understanding it.
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply
#7
(Sep-06-2018, 02:25 AM)Skaperen Wrote: i still don't understand what @sc does. i can't consider doing it without understanding it.
You know what @sc does:
@sc
def foo():
    ...
is equivalent to
def foo():
    ...
foo = sc(foo)
That said, sc() can be defined to do whatever you want to do, that's the great flexible thing about it.
Reply
#8
so, for example, Python does not need a type of looping structure to handle loop control of a variable first assigned in the body of the loop because it is easy enough (adding just one line of code before the loop to initialize that variable) to make it work with what Python has (while).
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply
#9
For loops, python has the iterator protocol. Very often you can avoid completely the control variable or its initialization.
Reply
#10
the feature where you can have an else clause follow a loop and be invoked if no breaks happened is not an essential feature. without it a flag can be used. initialize the flag as True before the loop, and set it to False before each break statement. then do if flag: following the loop.

syntactic sugar. not essential.

are Python coders syntactic diabetics?
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  what is your opinion of this syntactic sugar idea? Skaperen 8 4,461 Nov-28-2018, 03:15 AM
Last Post: Skaperen

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020