mdbergmann / cl-gserver

Sento - Actor framework featuring actors and agents for easy access to state and asynchronous operations.

Home Page:https://mdbergmann.github.io/cl-gserver/index.html

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Provide pre-configured agent for lists and arrays

Ambrevar opened this issue · comments

Since they are index-based, it makes sense to have a common interface for them. But CL uses nth for lists and elt for vectors, so it would not follow the standard here (which is my opinion not very convenient).

Otherwise they can be separate interfaces.

Do you think there is a need to cover ordinary lists at all?
List operations like cons and append are not destructive and return a new list which can more easily be used for swapping. nth of list, in particular together with setf, do you think this is really used? Since nth needs to traverse the list I'd imagine that such a use-case should use an array.

For arrays/vectors there is no question.

What about elt vs. aref. elt works on sequences, so also strings and such. Where aref is only used on vectors/arrays.

OK. So elt is actually more safe? Going beyond the fill-pointer sounds like going beyond the bounds of an array in C or so.

I'm a bit unsure here about the error handling.
The functionality that retrieves something like agent-elt, agent-pop, etc. can return a condition raised by elt, vector-pop, etc. That's ok.
But functionality that only happens by agent-update (internally uses tell) to only update internal state, any conditions raised by setf, vector-push, etc. would just be available as part of log4cl. But for the user that's not good enough I think. So I'm thinking about an error handler function the user can optionally pass that is called with the condition that was raised by the function (elt, ...). Then the user can decide what to do with it. Ignore, log, or whatever.

Finalized array-agent.
As part of this the interface also for hash-agent was slightly modified to streamline the interface.