Modified make_cons and make_frame to illustrate the pattern I

want to apply generally. This does not compile!
This commit is contained in:
Simon Brooke 2026-04-20 23:21:30 +01:00
parent 6148d3699f
commit aa5b34368e
6 changed files with 145 additions and 21 deletions

View file

@ -21,6 +21,47 @@ I'm not ignoring the fact that a lot of stuff in `0.1.0` is still fundamentally
I think this week is going to be mostly a thinking week — partly because the weather forecast is unusually benign, and it would be sensible get some outdoor work done.
### 21:30
Right, I have spent a lot of time hauling timber out of the wood today, but I've also done a substantial amount of coding, doing a sort of hybrid not-quite-standard-lisp calling convention; and I'm now convinced all this work is wrong and needs to be backed out, and I need to go for full on Lisp calling convention.
So where I'm now calling `make_cons` as in this sample:
```c
struct pso_pointer c_reverse( struct pso4* frame, struct pso_pointer sequence ) {
struct pso_pointer result = nil;
for ( struct pso_pointer cursor = sequence; !nilp( sequence );
cursor = c_cdr( cursor ) ) {
result = make_cons( frame, c_car( cursor ), result );
}
return result;
}
```
we would instead be doing this:
```c
struct pso_pointer reverse( struct pso_pointer frame) {
struct pso_pointer sequence = fetch_arg( frame, 0);
struct pso_pointer result = nil;
for ( struct pso_pointer cursor = sequence; !nilp( sequence );
cursor = cdr( make_frame( 1, frame, cursor ) ) {
result = cons( make_frame( 2, frame,
car( make_frame( 1, frame, cursor )),
result);
}
return result;
}
```
Note that instead of `c_reverse`, `c_cdr`, `c_car` this is using `reverse`, `cdr`, `car`. That's because these are actual Lisp functions, callable from Lisp, which don't have to be duplicated or wrapped in Lisp-compatible wrappers.
This *has* to be the right way to go.
## 20260415
OK, I have been diverted down a side-project on a side-project. I decided