Commit Graph

19 Commits

Author SHA1 Message Date
Aryadev Chavali
847eb1a69b Refactor vectors to SBO, removing inlined entirely.
Avoid 2 levels of indirection, and having to allocate twice for small
payloads, by having an inlined array on the vector directly!
Beautiful and simple.

Required a bit of refactoring around the board, but overall the result
makes me feel happier.
2025-08-20 23:37:08 +01:00
Aryadev Chavali
13142dc7f3 refactor lisp runtime to use vec_t* instead of ivec_t*
bit nicer to look at, should have about the same painful performance
hit anyway.
2025-08-20 22:43:23 +01:00
Aryadev Chavali
6e2db6825d Stable vector implementation
Stable vectors will be used in the lisp runtime to implement actual
vectors, instead of using the disgusting lvec trick.  This way we at
least can get attributes about the vector through one pointer hop.
2025-08-20 22:33:40 +01:00
Aryadev Chavali
2369185b26 remove parameter names in header 2025-08-20 22:33:31 +01:00
Aryadev Chavali
e1294a28cd ivec_ensure_remaining -> ivec_ensure_free 2025-08-20 22:32:45 +01:00
Aryadev Chavali
55293ae396 vec -> ivec
I'm going to implement a normal stable vector instead of an inline
vector so we have both options for use.  I think that's smarter than
just sticking to one.
2025-08-20 22:19:14 +01:00
Aryadev Chavali
df558da7e1 Use sv_t instead of raw char*
We're storing them as sv_t's anyway, we're fucked with regards to
indirection.  Thus, let's be nice to ourselves, and deal with the
structures.  We get the size of the structure for free anyway!
2025-08-20 21:50:58 +01:00
Aryadev Chavali
643896e2c8 rename base.h -> alisp.h
Makes more sense when you think about including it as an external
library
2025-08-20 21:24:07 +01:00
Aryadev Chavali
3074ba5bab Constructors and context -> sys
We can register memory we've allocated onto the heap into a ~sys_t~
instance for examination (read: garbage collection) later.  We can
also add items to the symbol table it has internally.
2025-08-20 21:12:46 +01:00
Aryadev Chavali
99396b0533 README 2025-08-20 00:10:34 +01:00
Aryadev Chavali
0d6b0de88d Basic template for a system context and constructors 2025-08-20 00:00:33 +01:00
Aryadev Chavali
f8c2ec86ae Test for tagging integers 2025-08-19 23:22:12 +01:00
Aryadev Chavali
779c4b8305 Conses and Vectors for my tagging scheme
Unfortunately, due to how vectors are implemented, pointers to them
are unstable.  We need to box them one more time (therefore adding a
level of indirection) in order to stabilise them.  This is annoying
but currently necessary.

Even if we implemented vectors as {u64, u64, ptr} instead of {u64,
u64, bytes...}, we'd still have the same problem at access - two
levels of indirection.  I guess size and capacity checks would be one
level of indirection which is nice at least, but we're already screwed
at the point of doing lookup either way.
2025-08-19 23:21:41 +01:00
Aryadev Chavali
7ac2a80b11 Pointer tagging!
Copied from oats, just the basics required for tagging integers or
symbols.
2025-08-19 23:08:35 +01:00
Aryadev Chavali
6dfe3e72a1 Make sym_table_find return the c-string in question directly
I think we fall into a few traps if we return an sv_t directly.  Think
intent is clearer by returning the c-string directly.
2025-08-19 23:02:07 +01:00
Aryadev Chavali
e7f4b0440c Add sanitisers to build 2025-08-19 22:55:20 +01:00
Aryadev Chavali
78aa7d6fb3 Separate out implementation to make looking at code files easier 2025-08-19 22:53:19 +01:00
Aryadev Chavali
b87a0c473a Separated out the definitions to clean up a bit
We're going to be using C to compile our Lisp eventually, so I need to
have a header file for compilation to work.  We can still separate out
the implementation details into separate files (then generate a shared
library for usage in the link stage) but we need this header file to
be singular and clean.
2025-08-19 22:47:57 +01:00
Aryadev Chavali
f14a2680fd 200 line symbol table implementation and the first commit
Setup build system (POSIX sh), gitignore, basic C file with an
implementation of something I really wanted to setup.

It just hashes a snippet of lorem ipsum.  Testing seems to indicate
it's working. That's all it does lol.

This is a really pressing matter; all my previous Lisps always just
made the strings on the fly and that irked me deeply.  I want a smart
implementation that really tries to save memory on something as
intensive as symbols.
2025-08-19 22:40:50 +01:00