My thinking about a better streams api (#64), opaque objects (#70), and also more than 1 extension support using metatables, I was thinking that these different aspects could all be stored in lookup tables in flash just like the core uLisp function lookup table. Something like this for streams (like in this comment of mine but with static lookup tables):
typedef struct {
PGM_P name;
pfun_t pfun;
gfun_t gfun;
// more fields as needed
} stream_entry_t;
const char serialstream[] PROGMEM = "serial";
// etc
const stream_entry_t streams_table[] PROGMEM = {
{ serialstream, pserial, gserial /* etc */},
// etc
};
And then gstreamfun() and pstreamfun() could use the lookup table in the same way as the main function lookup routines. This might even reduce the code size in the long run compared to two functions with if-statment pseudo-lookup-table things.
Additionally, the opaque types for the extension could also be put in a table, or at least the count of them or something.
And the metatable entries could be put in a statically allocated array (in RAM!), too, to avoid DMA on platforms that don't support it like AVR. Something like 8 or 16 slots for extensions seems appropriate.
p.s. what program do you use to draw the box-and-pointer diagrams on the uLisp website?
My thinking about a better streams api (#64), opaque objects (#70), and also more than 1 extension support using metatables, I was thinking that these different aspects could all be stored in lookup tables in flash just like the core uLisp function lookup table. Something like this for streams (like in this comment of mine but with static lookup tables):
And then
gstreamfun()andpstreamfun()could use the lookup table in the same way as the main function lookup routines. This might even reduce the code size in the long run compared to two functions with if-statment pseudo-lookup-table things.Additionally, the opaque types for the extension could also be put in a table, or at least the count of them or something.
And the metatable entries could be put in a statically allocated array (in RAM!), too, to avoid DMA on platforms that don't support it like AVR. Something like 8 or 16 slots for extensions seems appropriate.
p.s. what program do you use to draw the box-and-pointer diagrams on the uLisp website?