On Mon, Jan 22, 2024 at 04:15:23PM +0100, Prof. Dr. Johannes Grabmeier wrote:
> aha, this seems reasonable (but, who should know that?)
> 
> But, nevertheless problem is not solved: I now added a new exported function
> 
> init : () -> %
> 
> BUT: same behaviour,

AFAICS behaviour changes when you modify STEP.spad to remove 'constant',
recompile and than recompile your files.

However, you probably should re-think your design.  Without
mutation you can have several iterations going in parallel
(possibly in different functions).  With your approach
mutation to doman breaks all iterations in progress.

In general, math objects should be immutable, that is are
created once (possibly using mutation) during creation and
then used as long as needed.  Mutation of types should not
break this, that is valid math object should be effectively
"the same" even is domain is modified.  So mutation for
caching or change of print format are OK.  Also, domains
that effectively work as finite approximations to infite
object by using bigger and bigger finite objects are OK.

Coming back to your domain: change to StepTrough would probably
give behaviour that you want.  But such change is inappropriate,
as currently StepTrough behaves correctly with domains that
respect FriCAS design.  And even if 'init' problem would be
reloved as you like your domain will not play nice with the
rest of FriCAS library.

>From your code it is not clear what you really want/need.
Iteration could be done using generators (several years ago
I posted a simple implementation of generators for FriCAS).
Note that with generators you can have several ways of
iterationg other the same domain.  Unlike StepTrough there
is no need to create new domain only to have new iteration
pattern (of course you need separate implementations so
possibly separate package with generator(s), but base
domain stays the same).  Or maybe you can use streams (you
can think of streams as variant of generators that remembers
all values that were produced).

If you need more than iteration there is a question what operations
you need and do they depend on parameters?  If other operations
are independent of parameters, than things are easy.  If
operations depend on parameters than storing parameters
together with elements allows single domain.  Or use FriCAS
classics, that is parametrized types.

> I cannot use the category StepThrough in my case, because the code in the
> category uses the
> 
> init()-function with "contant". Obviously, implementing
> 
> init: constant -> %
> 
> there, one has not thought about the neccessity to switch that off in cases
> where the
> 
> domain has feature to change internal variables.

As I wrote changing _essential_ internal variables is really incompatible
with FriCAS design.

-- 
                              Waldek Hebisch

-- 
You received this message because you are subscribed to the Google Groups 
"FriCAS - computer algebra system" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/fricas-devel/Za830pHDj91LKHG-%40fricas.org.

Reply via email to