One thing I'm seeing is that the myriad ways of testing, recording information about, and even classifying functions can be elegantly handled by contexts.
All of my functions for testing are in the testing context. Documentation can be found in the docs context. I put my global functions into the user context. After that, I make the function name a global constant holding the user-function from user. A skeleton of a file following this pattern looks like this:
Code: Select all
(context 'user)
(define (f a b)
(+ a b (- b a)))
(context MAIN)
(constant (global 'f) user:f)
(define (docs:f) ; not making any new symbols
(show {f
syntax: (f int-a int-b)
What the function does.
example:
> (f 1 3)
6
> (f 3 1)
2
> _}))
(context 'testing) ; making new symbols
(define (testing:f) ; context is needed (not the global f)
(let (f. MAIN:f) ; and so is MAIN (not testing's f)
(test=
(f. 1 3) 6
(f. 3 1) 2
(f. 1 1) 2
(f. 3 3) 6)))
(context MAIN)
Now, at the command line:
Code: Select all
> (docs:f)
|
f
syntax: (f int-a int-b)
What the function does.
example:
> (f 1 3)
6
> (f 3 1)
2
> _
|
> (testing:f)
testing:passed
> ;; I also modified Lutz's *help* macro to use the function
> ;; in *docs* (if there is one) for all user-defined functions
> (help f)
|
f
syntax: (f int-a int-b)
What the function does.
example:
> (f 1 3)
6
> (f 3 1)
2
> _
|
> _
I think contexts are just begging to be explored for ways of structuring and reasoning about our newLISP programs.
This leads me back to somewhere close to where I started. And that is the acceptance of the language as it is. Nothing about a programming language is happenstance. Everything is there for a reason (although that reason may no longer be valid, hence the need for continual development). If I look at a language and see only ways it can be made more like this or that language, can I really say I'm seeing the language for what it is? If you look at your significant other and see only ways that person could be different, are you really accepting them as they are? Once you accept the language (and by this, I really mean its nature), you begin to see new ways of doing things and to feel the excitement of exploration again. With that, we can discover the beauty that is newLISP. If we were so impressed with our old language, why are we looking for another one?
As part of this exploration, I wondered if we could use contexts to classify even the built-in functions (lists, arrays, strings, maths, matrixes, i/o, etc). This way, we could see all the functions of certain types:
Code: Select all
> (symbols strings)
(strings:address strings:append strings:char strings:dup
strings:ends-with strings:encrypt strings:eval-string ...)
> _
I've really just started to think about the ways contexts can be used, but already, I'm seeing there is more there than meets the eye.
m i c h a e l