[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
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