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

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



Guy, you and I are both right, I believe.  My example is correct, but my
description is incorrect.

My example sets the value of dict["foo"] to 42 iff dict["foo"] was null,
as I wanted it to.  My description of / is, however, backwards as you
point out.  (I.e., the / computes the l-value iff the r-value *is*
null.)

Sorry for the confusion.

Todd

-----Original Message-----
From: Guy Steele - Sun Microsystems Labs [mailto:Guy.Steele@Sun.COM] 
Sent: Tuesday, May 28, 2002 9:10 AM
To: kragen@pobox.com; ll1-discuss@ai.mit.edu; Todd Proebsting
Subject: RE: orthogonality and generalized references (was Re: Zen of
Python)



   Date: Mon, 27 May 2002 17:57:55 -0700
   From: "Todd Proebsting" <toddpro@microsoft.com>

   
   Ages ago I posted to this list about goal-directed evaluation in
Icon.
   This "ifAbsentPut" discussion will, I hope, allow me to express
another
   advantage of goal-directed evaluation.  In Icon, the ifAbsentPut
idiom
   is the following simple expression---Icon has only expressions, and
not
   statements.
   
   /dict["foo"] := 42
   
   To understand this statement, you must understand the unary '/'
operator
   and the notion of goal-directed evaluation.  The '/' operator
computes
   the l-value (if one exists, otherwise the r-value) of its operand IFF
   the r-value is not null.  If the r-value is null, then the operation
   fails.  
   
Did you get the sense of null vs. non-null backwards in
your description here?   I believe that / fails iff the
r-value is not null.  See

  http://www.cs.arizona.edu/icon/refernce/prefix.htm#null

It is the \ operator that fails if its operand is null, right? So

  \dict["foo"] := 42

replaces the hash table entry with 42 iff the entry is non-null, but
leaves it alone if it is null.

--Guy Steele