On Sat, Mar 01, 2025 at 04:10:15PM +0000, Martin Baker wrote:
> On 01/03/2025 14:31, 'Ralf Hemmecke' via FriCAS - computer algebra
> system wrote:
> > Hi Martin,
> > 
> > without looking into topology.spad I guess the reason for you problem
> > comes from the line
> > 
> > h : Homset(source,target) := homset()
> 
> Thanks Ralf,
> 
> I have just tried what you suggested and I think you are correct.
> 
> As you suspected, this cleared the problem once it happened:
> )clear prop h
> 
> and calling it this way:
> h := homset() $ Homset(source,target)
> does not create the problem.
> 
> I would never have worked this out without your help. Are there any
> resources that would help SPAD programmers solve issues like this?

We probably should have somewhere information that:

h : Homset(source, target) := homset()

may lead to breakage when code is modified, while

h := homset()$Homset(source, target)

simply uses new type.

Beyond that, FriCAS told you that there is type mismatch, so normal
rule is to look at variable declaration.  While it is not obvious
_why_ type does not match, removing declaration fixes the problem.

Arguably, interpreter should notice that type really did not change,
but similar problems _are_ expected when you change types.  The
second variant adapts to changed types, while the first one leads
to trouble.  So, when developing code I prefer the second way
(but many online examples show the first one).

In introductory part of FriCAS book we have:

: A variable initially has no restrictions on the kinds of
: values to which it can refer.

: To restrict the types of objects that can be assigned to a variable,
: use a declaration
:
:   y : Integer
:
: After a variable is declared to be of some type, only values
: of that type can be assigned to that variable.

...

: A type declaration can also be given together with an assignment.
: The declaration can assist FriCAS in choosing the correct
: operations to apply.

But @ or $ are more specific, so there is really no reason to
declare type of variable when all what you need is proper choice
of operation.

> It
> would be good if there was information to help with debugging on
> fricas.github.io

There is info about debugging:

http://wiki.fricas.org/DebuggingFriCAS

and

doc/debug.txt

int the source tree.  However, it does not cover cases like yours.

> Many years ago, I tried to collect information that would help me with
> debugging and put it here as I found it:
> https://www.euclideanspace.com/prog/scratchpad/spad/debug/index.htm
> But that is just my random notes which may be incorrect and out-of-date,

At the start there is some confusion: you write that mode is Spad
jargon for type.  But that is more subtle.  Spad compiler does not
use modes, only types.  Modes are used by the interpreter.  Modes
differ from type in an important aspect: type is fully determined,
while mode contain undetermined part.  This is explained in
section 2.2.4 of the FriCAS book.

-- 
                              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 fricas-devel+unsubscr...@googlegroups.com.
To view this discussion visit 
https://groups.google.com/d/msgid/fricas-devel/Z8NCdn_N8ZS2kAUi%40fricas.org.

Reply via email to