Re: Why '==' ??

Discussion in 'Python' started by Fuzzyman, Apr 1, 2004.

  1. Fuzzyman

    Fuzzyman Guest

    Josiah Carlson <> wrote in message news:<c4e4j9$dtp$>...
    > > if a = 3
    > > print 'Yeah baby'
    > >
    > > are still *unambiguous*.... yet the interpreter refuses to understand
    > > you......

    >
    > Oh, the CPython interpreter understands you, it just doesn't like what
    > you say. I (and I'm sure the majority of other Python users) agree with
    > the interpreter, your modified syntax leaves something to be desired.
    >
    > You syntax also /makes ambiguous/ the following currently valid Python
    > syntax...
    >
    > if a == 3: \
    > print "hello"
    >
    > If we converted that to /your/ syntax, it would read...
    >


    Not at all...but there you go... you need to reread what I said :)

    > if a = 3 \
    > print "hello"
    >
    > Which would get internally translated to...
    >
    > if a = 3 print "hello"
    >
    > I don't think it makes sense, and I wouldn't expect an interpreter to
    > think it makes sense of it either.
    >
    >
    > > Theres no reason why a single '=' shouldn't be understood in a
    > > conditional....

    >
    > Except that it would be a 'special case' when two different syntactical
    > symbols mean the same thing.
    > "Special cases aren't special enough to break the rules."
    > - The Zen of Python, by Tim Peters
    >


    Not at all.
    No need for a special case. Leave '==' with the same meaning as it
    currently has... but give '=' a dual meaning (as it has in reality)
    with the meaning obvious from context. In 'multi statements' (or
    whatever the correct phrase is to pre-empt any more otiose comments)
    require '==' so the syntax is clear.

    Ie. If the meaning is obvious.... '=' can replace '=='... if it's
    not.. it can't...



    > > As for needing a ':' to allow statements after a 'def' or a
    > > conditional.... python already has the ';' for that... why insist on a
    > > ':'

    >
    > Do you even read the docs?


    Sorry.. didn't realise memorising the entire python documentation was
    a requirement before posting :p

    > Python does not have ';' to allow statements


    Actually - *you've* completely misread the sense of what I've written
    ;-)

    > after a def, Python has ';' because it allows you to place more than one
    > statement on a single line.


    Yup.

    > That is, it allows...
    > a = 1;b = 2;c = 3;
    >
    > /not/ because it allows the absolutely ugly:
    > def fun(a,b): print a,; print b;
    >
    > You should note that ':' is placed in syntactically different locations
    > than ';', because they have syntactically different meanings. ':' means
    > "there is some scope that is being enclosed",


    Which is unnecessary *as far as I can see* - because it's always
    obvious that some scope is being enclosed......... You've failed to
    show any case where that's not true. (Although I wouldn't be surprised
    if it was..).

    The reason some people stated it was necessary was to allow another
    statement on the same line... which is what I said ';' was for.

    Sorry if you enjoy flaming newbies....... but in this case you'r a bit
    off beam Josian old bean.............


    Regards,



    Fuzzy
    (Recent python convert)
    http://www.voidspace.org.uk/atlantibots/pythonutils.html


    > while ';' means "that is
    > the end of the previous statement".
    >
    >
    > - Josiah
     
    Fuzzyman, Apr 1, 2004
    #1
    1. Advertising

  2. > Not at all...but there you go... you need to reread what I said :)

    I've read what you said a few times. You say that using '=' instead of
    '==' in boolean tests is unambiguous. You also say that removing ':'
    is unambiguous.

    I attempted to show you an example where such modifications /are/ ambiguous.


    > Not at all.
    > No need for a special case. Leave '==' with the same meaning as it
    > currently has... but give '=' a dual meaning (as it has in reality)
    > with the meaning obvious from context. In 'multi statements' (or
    > whatever the correct phrase is to pre-empt any more otiose comments)
    > require '==' so the syntax is clear.
    >
    > Ie. If the meaning is obvious.... '=' can replace '=='... if it's
    > not.. it can't...


    The problem is that having multiple ways (syntactically) to do the exact
    same thing causes people to ask questions like "which one is better".
    There is an entire thread about this with regards to tabs vs. spaces in
    this newsgroup, and thousands of threads available as to where {} in
    C/C++ or Java should be located across the internet.

    By saying "use it this way when it is unambiguous" and "use it this way
    when it is ambiguous", you are attempting to complicate the syntax of
    Python. Why? To save a few keystrokes.

    "There should be one-- and preferably only one --obvious way to do it."
    - The Zen of Python, by Tim Peters


    > The reason some people stated it was necessary was to allow another
    > statement on the same line... which is what I said ';' was for.


    I'm pretty sure the choice of ';' to end statements was to mirror
    various languages that people trying Python would likely be familliar
    with. Considering these same languages have little to no use for the
    ':' character (except for C++), its use in Python would be unambiguous.

    Considering that in C, the following is a no-op, regardless of what a
    actually is...
    if (a);

    But in Python, different things /would/ actually happen based on the
    contents of a, so would introduce ambiguity for those people coming from
    a C/C++ background, needlessly.


    > Sorry if you enjoy flaming newbies....... but in this case you'r a bit
    > off beam Josian old bean.............


    It wasn't a flame, it was an unkind post saying that your proposed
    syntax options were crap. I'm fairly certain that Guido looked at quite
    a few options when trying to decide on proper syntaxes early on, so that
    he didn't make any major mistakes. I am also fairly certain that the
    reason that your proposed syntax isn't what is currently done, is due to
    its ambiguity from the point of view of a C/C++ programmer.

    - Josiah
     
    Josiah Carlson, Apr 1, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?VGltOjouLg==?=

    Why, why, why???

    =?Utf-8?B?VGltOjouLg==?=, Jan 27, 2005, in forum: ASP .Net
    Replies:
    6
    Views:
    589
    Juan T. Llibre
    Jan 27, 2005
  2. Horace Nunley

    why why why does function not work

    Horace Nunley, Sep 27, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    483
    =?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=
    Sep 27, 2006
  3. Mr. SweatyFinger

    VWD why why why

    Mr. SweatyFinger, Nov 28, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    400
    =?Utf-8?B?Q2lhcmFuIE8nJycnRG9ubmVsbA==?=
    Dec 21, 2006
  4. Mr. SweatyFinger

    why why why why why

    Mr. SweatyFinger, Nov 28, 2006, in forum: ASP .Net
    Replies:
    4
    Views:
    935
    Mark Rae
    Dec 21, 2006
  5. Mr. SweatyFinger
    Replies:
    2
    Views:
    2,129
    Smokey Grindel
    Dec 2, 2006
Loading...

Share This Page