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

Lisp Help!!



The CL toddler has found his way to the Net!

Here is a problem which feels like I am stuck in C-think:

I need to keep track of "where-the-user-is" as they navigate a classic Lisp
tree: a list of lists. (I am writing an editor, and need to represent the
cursor position statically during event processing.) The tree can contain
nils, representing required stuff before they have typed it, or even the
whole tree before they have typed anything.

OK, enough of that, here's the Q: how do I represent statically being
"at-the-end-of-a-given-sub-list"? Other places, I have the "car", the thing
pointed to. At the end, I have "nil", but in a tree I would have many nils,
so I could not distinguish them.

I am hoping to avoid unpleasantries (?!) such as a faux object to mark the
end of a list.

One thought I had was to represent the position as a lambda (car/cdr
<some-cons-cell>), but that would be dumb: what happens when I re-cons in
light of their editing?

I *can* traverse these lists by hard-coding pauses at the end of lists, so
that makes me wonder if something like a Scheme continuation would be in
order? But then my budding Lisp consciousness collapses trying to grok a
continuation as a place!

A before-after pair of atoms is tempting. Traversal-wise it *is* possible
for (nil nil) pairs to arise, but I can define the "before" guy I think
differently than as "the-prior-traversal-point", in which case I think I
can avoid (nil nil).

Hmm. That would work. I guess I am kinda hoping there is some beautiful way
of denoting "the end of *that* sub-list" even in the face of a
re-consing...almost answering my own Q, aren't I? <g>

OK, I'm going to try to make before-after work. Any enlightenment very
welcome, whomsoever.

Cheers!