[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: orthogonality and generalized references (was Re: Zen of Python)




   Date: Tue, 28 May 2002 14:54:55 -0700
   From: "Todd Proebsting" <toddpro@microsoft.com>
   
   Thank you, Guy, for omitting the "Why didn't you enumerate all *four*
   possibilities?" that others less kind might have asked pointedly.  I
   will enumerate all four, leaving the two you discuss below adjacent.
   
       WITH GOAL-DIRECTION            WITHOUT GOAL-DIRECTION
    dict["foo"] :=  dict["bar"]      dict["foo"] :=  dict["bar"]
   
    dict["foo"] := \dict["bar"]      tmp := dict["bar"]
                                     if tmp is not null then
                                        dict["foo"] := tmp
   
   /dict["foo"] :=  dict["bar"]      lval := lvalueOf(dict["foo"])
                                     if rvalueOf(lval) is null then
                                        tmp := dict["bar"]
                                        rvalueOf(lval) := tmp
   
   /dict["foo"] := \dict["bar"]      lval := lvalueOf(dict["foo"])
                                     if rvalueOf(lval) is null then
                                        tmp := dict["bar"]
                                        if tmp is not null then
                                           rvalueOf(lval) := tmp
   
   
   To me, the difference between the last two is *less* clear when written
   without the unary operators (right column) because the second null test
   is lost in a sea of characters.  With the unary operators and GD (left
   column), it's clear that the difference is whether or not a null value
   can be assigned to the (previously null) left-hand side.  I consider
   this an example of why concise/succinct/terse languages can be clearer
   than less concise languages.  It's a balance.
   
   Of course, what makes Guy's example "subtle" is that a little reasoning
   about the values involved indicates that the two are behaviorally
   indistinguishable.

But what makes it even more subtle, if I understand
correctly, is that *in Icon* they are not behaviorally
indistinguishable, precisely because when the left-hand
side and right-hand side are both null,

  /dict["foo"] :=  dict["bar"]

*succeeds* (and overwrites a null with a null) but

  /dict["foo"] := \dict["bar"]

*fails*, and that could affect the further control flow of an
Icon program containing such a statement, right?

--Guy