Re: C++ program as a Lisp expression
- From: Ken Tilton <kennytilton@xxxxxxxxxxxxx>
- Date: Fri, 30 May 2008 01:55:38 -0400
Dihydrogen Monoxide wrote:
On Thu, 29 May 2008 22:10:33 -0400, Ken Tilton wrote:
Dihydrogen Monoxide wrote:
On Wed, 19 Mar 2008 21:24:00 +0000, Pixel // pinterface wrote:
People have been trying to give Lisp a more ALGOL-inspired syntax since
the day McCarthy discovered Lisp. It originally started with
M-Expressions[1]; at one point there was Dylan[2]. Many other attempts
were made. But in spite of years of attempts by various people to
shirk the parenthesi, Lispers still use S-expressions.
Maybe--just maybe--you'll manage to pull people from the C++ side
closer to lisp, but if history is any indication you aren't likely to
attract many lispers. They've tried other syntaxes and found them
wanting.
I know the ()s are scary at first, but you get used to them, and
eventually take them for granted.
[1] http://en.wikipedia.org/wiki/M-expression [2]
http://en.wikipedia.org/wiki/Dylan_%28programming_language%29
And yes, this is just a more verbose version of what His Kennyness
already stated.
Oooh me like Dylan. Shouldn't that be Kenniness?
The first link on M-expressions says it all. While McCarthy was still
doing the Chief Science Officer thing and "knew" from first principles
or something that no one should be programming explicitly with the
internal structure, the other people on the team were Actually
Programming(tm) with Lisp and knew otherwise.
Now enjoy this because it may be the only time it ever happens:
What do you and McCarthy have in common?
Cure that and you can have the keys to c.l.l. I am being eased out to
Poster Emeritus and you seem to be able to write without putting me to
sleep.
kt
well, let me take that the way it was meant
loud n clear capn - expect something at the blogspot like tomorrow afternoon
i'll be using " _" and "_ " as my eyes take priority
there's a kind of beauty to " " + "_" + char, it makes even the delimiter a program!
Lessee, I have been cleaning up the code just hoping and praying that someday Pascal the Magnificent Costanza would deign to look at it, maybe you can help. I started with this:
(defmethod ensure-value-is-current (c debug-id ensurer)
;
; ensurer can be used cell propagating to callers, or an existing caller who wants to make sure
; dependencies are up-to-date before deciding if it itself is up-to-date
;
(declare (ignorable debug-id ensurer))
(count-it :ensure-value-is-current)
;; (trc c "ensure-value-is-current > entry" c (c-state c) :now-pulse *data-pulse-id* debug-id ensurer)
(when *not-to-be*
(when (c-unboundp c)
(error 'unbound-cell :cell c :instance (c-model c) :name (c-slot-name c)))
(return-from ensure-value-is-current
(when (c-validp c) ;; probably accomplishes nothing
(c-value c))))
(when (and (not (symbolp (c-model c))) ;; damn, just here because of playing around with global vars and cells
(eq :eternal-rest (md-state (c-model c))))
(break "model ~a of cell ~a is dead" (c-model c) c))
(cond
((c-currentp c)
(trc nil "EVIC yep: c-currentp" c)) ;; used to follow c-inputp, but I am toying with letting ephemerals (inputs) fall obsolete
;; and then get reset here (ie, ((c-input-p c) (ephemeral-reset c))). ie, do not assume inputs are never obsolete
;;
((and (c-inputp c)
(c-validp c) ;; a c?n (ruled-then-input) cell will not be valid at first
(not (and (typep c 'c-dependent)
(eq (cd-optimize c) :when-value-t)
(null (c-value c))))))
((or (not (c-validp c))
;;
;; new for 2006-09-21: a cell ended up checking slots of a dead instance, which would have been
;; refreshed when checked, but was going to be checked last because it was the first used, useds
;; being simply pushed onto a list as they come up. We may need fancier handling of dead instance/cells
;; still being encountered by consulting the prior useds list, but checking now in same order as
;; accessed seems Deeply Correct (and fixed the immediate problem nicely, always a Good Sign).
;;
(labels ((check-reversed (useds)
(when useds
(or (check-reversed (cdr useds))
(let ((used (car useds)))
(ensure-value-is-current used :nested c)
#+slow (trc c "comparing pulses (ensurer, used, used-changed): " c debug-id used (c-pulse-last-changed used))
(when (> (c-pulse-last-changed used)(c-pulse c))
#+slow (trc c "used changed and newer !!!!!!" c :oldpulse (c-pulse used) debug-id used :lastchg (c-pulse-last-changed used))
#+shhh (when (trcp c)
(describe used))
t))))))
(assert (typep c 'c-dependent))
(check-reversed (cd-useds c))))
#+shhh (trc c "kicking off calc-set of" (c-state c) (c-validp c) (c-slot-name c) :vstate (c-value-state c)
:stamped (c-pulse c) :current-pulse *data-pulse-id*)
(calculate-and-set c))
((mdead (c-value c))
(trc nil "ensure-value-is-current> trying recalc of ~a with current but dead value ~a" c (c-value c))
(let ((new-v (calculate-and-set c)))
(trc nil "ensure-value-is-current> GOT new value ~a to replace dead!!" new-v)
new-v))
(t (trc nil "ensuring current decided current, updating pulse" (c-slot-name c) debug-id)
(c-pulse-update c :valid-uninfluenced)))
(when (c-unboundp c)
(error 'unbound-cell :cell c :instance (c-model c) :name (c-slot-name c)))
(bwhen (v (c-value c))
(if (mdead v)
(progn
#+shhh (format t "~&on pulse ~a ensure-value still got and still not returning ~a dead value ~a" *data-pulse-id* c v)
nil)
v)))
His Costanzaness does not play such. So I cleaned it up:
(defmethod ensure-value-is-current (c debug-id ensurer)
(cond
((c-currentp c)
(c-value c))
((and (c-inputp c)
(c-validp c)
(not (and (typep c 'c-dependent)
(eq (cd-optimize c) :when-value-t)
(null (c-value c))))))
((or (not (c-validp c))
(labels ((check-reversed (useds)
(when useds
(or (check-reversed (cdr useds))
(let ((used (car useds)))
(ensure-value-is-current used :nested c)
(> (c-pulse-last-changed used)(c-pulse c)))))))
(check-reversed (cd-useds c)))
(mdead (c-value c)))
(calculate-and-set c))
(t (c-pulse-update c :valid-uninfluenced))))
But I still do not see Pascal the Latter tolerating such. Turning to what I take to be your scheme:
_defmethod ensure-value-is-current _c debug-id ensurer_
_cond
_ _c-currentp c_ _
_ _and _c-inputp c_
_c-validp c_
_not _and _typep c 'c-dependent_
_eq _cd-optimize c_ :when-value-t_
_null _c-value c_ _ _ _ _ _
_ _or _not _c-validp c_ _
_labels _ _check-reversed _useds_
_when useds
_or _check-reversed _cdr useds_ _
_let _ _used _car useds_ _ _
_ensure-value-is-current used :nested c_
_> _c-pulse-last-changed used_ _c-pulse c_ _ _ _ _ _ _
_check-reversed _cd-useds c_ _ _
_mdead _c-value c_ _ _
_calculate-and-set c_ _
_t _c-pulse-update c :valid-uninfluenced_ _ _ _
I think all it needs is camelCase! Where were you fifty years ago!!?
kzo
--
http://smuglispweeny.blogspot.com/
http://www.theoryyalgebra.com/
ECLM rant: http://video.google.com/videoplay?docid=-1331906677993764413&hl=en
ECLM talk: http://video.google.com/videoplay?docid=-9173722505157942928&q=&hl=en
.
- Follow-Ups:
- Re: C++ program as a Lisp expression
- From: Pascal Costanza
- Re: C++ program as a Lisp expression
- References:
- Re: C++ program as a Lisp expression
- From: Dihydrogen Monoxide
- Re: C++ program as a Lisp expression
- From: Ken Tilton
- Re: C++ program as a Lisp expression
- From: Dihydrogen Monoxide
- Re: C++ program as a Lisp expression
- Prev by Date: Re: Errors when using Maxima code
- Next by Date: Re: New notation
- Previous by thread: Re: C++ program as a Lisp expression
- Next by thread: Re: C++ program as a Lisp expression
- Index(es):