On Wed, Apr 03, 2024 at 07:09:41PM +0200, Ralf Hemmecke wrote:
> On 4/3/24 18:41, Waldek Hebisch wrote:
> > Well, AFAICS this is one of limitations of current compiler: 'error'
> > gets special treatment, but only when it is translated to Boot
> > function called 'error'.  If you rename 'error3' to 'error', then
> > the file will compile.  But I expect that such rename will cause
> > trouble, so I do not think it is a practical solution.
> 
> That actually brings me to the question whether overloading in BOOT is also
> supposed to work, i.e., whether I can have
> 
> error(x) == errorSupervisor($AlgebraError,x)
> 
> error(con, fun, mess) ==
>     errorSupervisor($AlgebraError, [STRCONC(fun, '" $ ", con, '": "), mess])
> 
> at the same time. I guess no.

There is no overloading in Boot.

> However, your statement about the declarations bothered me a bit.
> First of all, I do not think that declaring the types of variables is a bad
> idea, since it is an easy hint for the programmer to understand the code. So
> that point of your "suboptimal" does not count for me.
> However, you say something about "weakens compiler checking", and that I
> don't understand at all. Up to know I would have guessed that when I declare
> the type of a variable, the compiler also checks that in places where this
> variable is used (or assigned), the actual types match with what I have
> declared. Is this not the case?

Yes.  However, here there is question of tracking values.  If you
give types you should do

     x : T := v

and not

     x : T
     ...
     x := v

The point is that type should be assigned to variable together with
value.  That way uninitialized variable leads to type error.
Declaring type in advance (before assignment) effectively disables
detection of uninitialized variables.  Sometimes Spad can not
see that variable is initialized with correct type, then we have
to give declaration in advance.  But if possible such advance
declarations should be avoided.

-- 
                              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/Zg2WegcWSlyYw1bk%40fricas.org.

Reply via email to