A critic of Guido's blog on Python's lambda

Ken Tilton kentilton at gmail.com
Sun May 7 12:36:12 EDT 2006



Ken Tilton wrote:
> 
> 
> Serge Orlov wrote:
> 
>> Ken Tilton wrote:
>>
>>> It is vastly more disappointing that an alleged tech genius would sniff
>>> at the chance to take undeserved credit for PyCells, something probably
>>> better than a similar project on which Adobe (your superiors at
>>> software, right?) has bet the ranch. This is the Grail, dude, Brooks's
>>> long lost Silver Bullet. And you want to pass?????
>>>
>>> C'mon, Alex, I just want you as co-mentor for your star quality. Of
>>> course you won't have to do a thing, just identify for me a True Python
>>> Geek and she and I will take it from there.
>>>
>>> Here's the link in case you lost it:
>>>
>>>     http://www.lispnyc.org/wiki.clp?page=PyCells
>>>
>>> :)
>>>
>>> peace, kenny
>>>
>>> ps. flaming aside, PyCells really would be amazingly good for Python.
>>> And so Google. (Now your job is on the line. <g>) k
>>
>>
>>
>> Perhaps I'm missing something...
> 
> 
> yes, but do not feel bad, everyone gets confused by the /analogy/ to 
> spreadsheets into thinking Cells /is/ a spreadsheet. In fact, for a 
> brief period I swore off the analogy because it was so invariably 
> misunderstood. Even Graham misunderstood it.
> 
> But it is such a great analogy! <sigh>
> 
>> but what's the big deal about PyCells?
>> Here is 22-lines barebones implementation of spreadsheet in Python,
>> later I create 2 cells "a" and "b", "b" depends on a and evaluate all
>> the cells. The output is
>>
>> a = negate(sin(pi/2)+one) = -2.0
>> b = negate(a)*10 = 20.0
> 
> 
> Very roughly speaking, that is supposed to be the code, not the output. 
> So you would start with (just guessing at the Python, it has been years 
> since I did half a port to Python):
> 
>   v1 = one
>   a = determined_by(negate(sin(pi/2)+v1)
>   b = determined_by(negate(a)*10)
>   print(a) -> -2.0 ;; this and the next are easy
>   print(b) -> 20
>   v1 = two ;; fun part starts here
>   print(b) -> 40 ;; of course a got updated, too
> 
> The other thing we want is (really inventing syntax here):
> 
>   on_change(a,new,old,old-bound?) print(list(new, old, old-bound?)
> 
> Then the print statements Just Happen. ie, It is not as if we are just 
> hiding computed variables behind syntax and computations get kicked off 
> when a value is read. Instead, an underlying engine propagates any 
> assignment throughout the dependency graph before the assignment returns.
> 
> My Cells hack does the above, not with global variables, but with slots 
> (data members?) of instances in the CL object system.

here it is:

(in-package :cells)

(defmodel useless () ;; defmodel is CLOS defclass plus Cells wiring
   ((one :initform nil :accessor one :initarg :one)
    (a :initform nil :accessor a :initarg :a)
    (b :initform nil :accessor b :initarg :b)))

;; defobserver defines a CLOS method just the right way

(defobserver one (self new-value old-value old-value-bound-p)
   (print (list :observing-one new-value old-value old-value-bound-p)))

(defobserver a (self new-value old-value old-value-bound-p)
   (print (list :observing-a new-value old-value old-value-bound-p)))

(defobserver b (self new-value old-value old-value-bound-p)
   (print (list :observing-b new-value old-value old-value-bound-p)))

;; c-in and c? hide more Cells wiring. The long names are c-input and 
c-formula, btw

(progn
   (print :first-we-make-a-useless-instance)
   (let ((u (make-instance 'useless
              :one (c-in 1) ;; we want to change it later, so wrap as 
input value
              :a (c? (- (+ (sin (/ pi 2)) (one self)))) ;; 
negate(sin(pi/2)+one)
              :b (c? (* (- (a self) 10)))))) ;; negate(a)*10
     (print :now-we-change-one-to-ten)
     (setf (one u) 10)))

#| output of the above

:first-we-make-a-useless-instance
(:observing-one 1 nil nil)
(:observing-a -2.0d0 nil nil)
(:observing-b -12.0d0 nil nil)
:now-we-change-one-to-ten
(:observing-one 10 1 t)
(:observing-a -11.0d0 -2.0d0 t)
(:observing-b -21.0d0 -12.0d0 t)

|#

kenny

-- 
Cells: http://common-lisp.net/project/cells/

"Have you ever been in a relationship?"
    Attorney for Mary Winkler, confessed killer of her
    minister husband, when asked if the couple had
    marital problems.



More information about the Python-list mailing list