Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Christopher Reimer Newsgroups: comp.lang.python Subject: Re: Assignment Versus Equality Date: Sun, 26 Jun 2016 11:47:25 -0700 Lines: 68 Message-ID: References: <8a53c069-ca13-47bf-a24e-d2393a018b22@googlegroups.com> <576fd6e0$0$1617$c3e8da3$5496439d@news.astraweb.com> <2588c5b2-4b6f-cfbb-f91e-4db03aa50318@icloud.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-Trace: news.uni-berlin.de RTKiGrG1920E0CDmJgsGzQqNKLaR4+Pyic+CqjLJ64kg== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.008 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; '(of': 0.07; 'assignment': 0.07; 'ambiguity': 0.09; 'beginners': 0.09; 'confuse': 0.09; 'snippet': 0.09; 'python': 0.10; 'python.': 0.11; 'language,': 0.11; 'interpreter': 0.15; '"="': 0.16; '*almost*': 0.16; '2016': 0.16; 'assignment.': 0.16; 'begging': 0.16; 'commercially': 0.16; 'comparison.': 0.16; 'compilers': 0.16; 'equality.': 0.16; 'expressions.': 0.16; 'ops': 0.16; 'personally,': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'wrote:': 0.16; 'obviously': 0.16; "wouldn't": 0.16; 'copied': 0.18; 'numerical': 0.18; 'tree': 0.18; '>>>': 0.20; 'lawrence': 0.22; 'pascal': 0.22; 'programming': 0.22; 'am,': 0.23; 'bit': 0.23; 'absolute': 0.23; "haven't": 0.24; 'second': 0.24; 'header:User-Agent:1': 0.26; 'appear': 0.26; 'chris': 0.26; 'coding': 0.27; 'gnu': 0.27; 'mathematical': 0.27; 'received:17': 0.27; 'regular': 0.29; '(it': 0.29; 'closer': 0.29; 'context,': 0.29; 'equality': 0.29; 'operators': 0.29; 'ronald': 0.29; 'code:': 0.29; "i'm": 0.30; 'print': 0.30; '(including': 0.30; 'certainly': 0.30; 'convention': 0.30; "i'd": 0.31; 'rules': 0.31; "can't": 0.32; 'received:10.0.0': 0.32; 'good.': 0.32; 'language.': 0.32; 'getting': 0.33; "d'aprano": 0.33; 'steven': 0.33; 'languages': 0.34; 'structure': 0.34; 'received:10.0': 0.34; 'next': 0.35; 'could': 0.35; 'community': 0.36; 'but': 0.36; 'should': 0.36; 'there': 0.36; 'basic': 0.36; 'success.': 0.36; 'to:addr:python- list': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'received:10': 0.37; 'agree': 0.37; 'version': 0.38; 'why': 0.39; 'sure': 0.39; 'enough': 0.39; 'well.': 0.40; 'to:addr:python.org': 0.40; 'where': 0.40; 'mark': 0.40; 'still': 0.40; 'header:MIME- version:1': 0.60; 'skip:u 10': 0.61; 'more': 0.63; 'different': 0.63; 'complete': 0.63; 'face': 0.64; 'between': 0.65; 'experience.': 0.66; 'virtually': 0.66; 'here': 0.66; 'repeat': 0.67; 'experts': 0.70; 'feeling': 0.72; 'commercial': 0.73; 'computing.': 0.84; 'confusion.': 0.84; 'delphi': 0.84; 'dialect': 0.84; 'header:In-reply-to:1': 0.84; 'loses': 0.84; 'mistakes.': 0.84; 'tell:': 0.84; 'world!"': 0.84; 'mistakes': 0.95 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2016-06-26_10:,, signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 clxscore=1015 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1510270003 definitions=main-1606260210 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.1.1 In-reply-to: <576fd6e0$0$1617$c3e8da3$5496439d@news.astraweb.com> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=icloud.com; s=4d515a; t=1466966844; bh=arI/GK/OZWN2eX+MgV0t0WesOaF4lQD2GzqOLqwdgUo=; h=Subject:To:From:Message-id:Date:MIME-version:Content-type; b=ppfB6Byb3WIKv4jT89TAaIW9P+KrhUGzCHyCjvhx2/1/fHGDpsVb/89Zjb3q9uUoe 38LTsLVY7A2hANLmoEM+UxkqJs2b9rXF04N4TLIqIQ7vAK8YNNy+w2bssAvmDepHu/ lrjMzRJKtpwksxEm3edffzDn/y0le6VOO2hgQhONyHBfX81HL3a+MKLfhiIugqWEY3 fhf7++pps574yy4Te0Lw32yTchM8guXJnpZSUufdoiLWWfB4rLcqdm5SQzoPm9LCyS V0jp1nxJVjrBZAzLf8QqhSsfKVCCqYBkBIt5CqvplgGyKsNh2kwd2IjcUTUEf1u5yu eXwAUb2940h7w== X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Mailman-Original-Message-ID: <2588c5b2-4b6f-cfbb-f91e-4db03aa50318@icloud.com> X-Mailman-Original-References: <8a53c069-ca13-47bf-a24e-d2393a018b22@googlegroups.com> <576fd6e0$0$1617$c3e8da3$5496439d@news.astraweb.com> Xref: csiph.com comp.lang.python:110538 On 6/26/2016 6:21 AM, Steven D'Aprano wrote: > On Sun, 26 Jun 2016 08:48 pm, BartC wrote: > >> On 26/06/2016 08:36, Lawrence D’Oliveiro wrote: >>> One of Python’s few mistakes was that it copied the C convention of using >>> “=” for assignment and “==” for equality comparison. >> One of C's many mistakes. Unfortunately C has been very influential. >> >> However, why couldn't Python have used "=" both for assignment, and for >> equality? Since I understand assignment ops can't appear in expressions. > Personally, I think that even if there is no *syntactical* ambiguity between > assignment and equality, programming languages should still use different > operators for them. I must admit that my first love is still Pascal's := > for assignment and = for equality, but C's = for assignment and == for > equality it *almost* as good. > > (It loses a mark because absolute beginners confuse the assignment = for the > = in mathematics, which is just different enough to cause confusion.) > > But the BASIC style = for both assignment and equality is just begging for > confusion. Even though = is not ambiguous given BASIC's rules, it can still > be ambiguous to beginners who haven't yet digested those rules and made > them second nature. > > And even experts don't always work with complete statements. Here is a > snippet of BASIC code: > > X = Y > > Is it an assignment or an equality comparison? Without seeing the context, > it is impossible to tell: > > 10 X = Y + 1 > 20 IF X = Y GOTO 50 > > > Now obviously BASIC was a very popular and successful language, for many > years, despite that flaw. But I wouldn't repeat it in a new language. > > >>> It should have copied the old convention from Algol-like languages >>> (including Pascal), where “:=” was assignment, so “=” could keep a >>> meaning closer to its mathematical usage. >> (I think Fortran and PL/I also used "=" for assignment. Both were more >> commercially successful than Algol or Pascal.) > Fortran 77 used .EQ. for equality. I'm not sure about PL/I. > > I'm also not sure I'd agree about the commercial success. Fortran certainly > has been extremely popular, albeit almost entirely in numerical computing. > But PL/I has virtually disappeared from the face of the earth, while Pascal > still has a small but dedicated community based on FreePascal, GNU Pascal, > and Delphi. > > (Of the three, FreePascal and Delphi appear to still be getting regular > releases.) I started writing a BASIC interpreter in Python. The rudimentary version for 10 PRINT "HELLO, WORLD!" and 20 GOTO 10 ran well. The next version to read each line into a tree structure left me feeling over my head. So I got "Writing Compilers & Interpreters: An Applied Approach" by Ronald Mak (1991 edition) from Amazon, which uses C for coding and Pascal as the target language. I know a little bit of C and nothing of Pascal. Translating an old dialect of C into modern C, learning Pascal and figuring out the vagaries of BASIC should make for an interesting learning experience. Chris R.