On 06/28/2016 07:33 AM, oldk1331 wrote:
>  > Actually, I would have expected [5,2,3,4]
> 
> But do you expect this:
> 
> (1) -> x:=arrayStack[1,2,3,4]
> 
>     (1)  [1,2,3,4]
>                                              Type: ArrayStack(PositiveInteger)
> (2) -> y := parts x
> 
>     (2)  [1,2,3,4]
>                                                    Type: List(PositiveInteger)
> (3) -> y.1 := 5
> 
>     (3)  5
>                                                          Type: PositiveInteger
> (4) -> x
> 
>     (4)  [1,2,3,4]
>                                              Type: ArrayStack(PositiveInteger)

Yes and no. It's underspecified and thus anything can happen.

I would bet that if the List domain in FriCAS would have been
implemented by an array-like datastructure, you would have seen
[1,2,3,4] in your first example (Stack) and [5,2,3,4] in ArrayStack.

Honestly, I don't know whether copying arguments should be a hard rule.
It depends on the application which one is more efficient. And... as
long as no destructive operations are used, everything is fine anyway.

> You are against destructive operations and concerns too much
> copying, it seems that Haskell really suits you :-)

Maybe, but I tried Haskell a little and still like SPAD better. I also
use destructive operations sometimes, especially when I design a new
domain, but then I have imposed the following rule (at least for me):

No destructive operation of domain D is allowed to modify any shared
memory of x and the outside world if such an operation is applied to
copy(x).

That's not what you are talking about, but better than nothing. Years
ago I was exactly at your stage. I crashed the system and introduced
bugs just because I used too many destructive functions to speed up my
program. In particular in the aldor-combinat project, I had a weired bug
that only occurred in a very special situation (recursive definition of
a datastructure). That was due to the destructive way in which I
modified the underlying datastructure.

Ralf

-- 
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 post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/fricas-devel.
For more options, visit https://groups.google.com/d/optout.

Reply via email to