[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
re: heirarchical lists, one more time.
I can't spell heirarchical so I will call them "deep lists".
I have been working on a not-quite-ready-for-prime-time shell (based
somewhat on rc) with deep lists for over a year. So I have a little
experience with the pain of dealing with these things in a shell
environment. The worst problem I encounterd was that the obvious
; path = (/usr/frob $path)
doesn't work because path now looks like
path = (/usr/frob (/bin /usr/bin /homes/quanstro/bin ...))
The first thing that I though of was making the pathsearch look down
the nested lists for the proper directory. And I was even stupid
enough to write the code for this which was huge and ugly. The obvious
solution was to add a scheme-like append operator (^^) with the
property (for strings fu and bar):
fu ^^ bar -> (fu bar)
(fu) ^^ bar -> (fu bar)
fu ^^ (bar) -> (fu bar)
(fu bar baz) ^^ fu -> (fu bar baz)
((fu)) ^^ bar -> ((fu) bar)
So now
; path = /usr/frob ^^ $path
works just as expected with little pain. A few other functions like
mkflatlist are all that's needed to complete making the shell's deep
lists painless (as long as you remember that it's not rc).