On 11/7/23 02:29, Waldek Hebisch wrote:
Yes, exactly that is the point. qnew claims to return an object of type %,
but, in fact, it doesn't.
Well, result of 'qnew' is uninitialized, but this does not differ
much from (note no initialization)
a : T
Maybe technically (i.e. how it is implemented in the compiler) it gives
similar things, but conceptually, I would say that "a:T" is different.
It is a declaration and thus just a hint to the compiler/interpreter
that when this identifier is used it is to be considered as something of
type T. However, I would expect the compiler to yell at me when I write
code like
=======================
)abbrev package FOO Foo
Foo: E == I where
E ==> with
foo: () -> Integer
I ==> add
foo(): Integer ==
a: Integer
b: Integer := a
=======================
Unfortunately, it doesn't. :-(
Would you say that a does not have type T?
It has type T, but after a declaration a:T, there is not yet reservation
of memory on my computer, so in fact, I do not yet have a variable, just
a hint to the compiler that the identifier "a" has type T when it comes
to type checking.
We could add the followowing to description of 'qnew':
Use only when you know what you are doing.
That is one thing, but does not give enough information. How should a user
know what he is doing? Where would he get this information from?
One of fundamental commandments of programming is:
"Thou shall not attempt to read uninitialized variables"
Of course. But putting a big warning sign is much better than just
mystically saying "Use only when you know what you are doing." and not
telling where to get information about it. It is like saying "Do not use
this function, because we are not telling you what it does."
I do not quite get your rejection of more informative documentation.
Put whatever you want into the ++ docstring.
I just wanted to say that I am more on the side of having documentation
that does not require uses to look at the code in order to understand
what a function does.
This is general programming knowledge, to get such knowledge
Dijkstra "Discipline of programming" may be good start.
Are you saying that people how haven't read this, should not use FriCAS?
I fear that then many mathematicians are excluded from or shy away from
FriCAS.
But there is more to this: people may think that someting like
a := qnew(4, 4)$Matrix(Float)
b := a(1,1) - a(1, 1)
Why? a(1,1) is clearly the same as elt(a,1,1), i.e. use of a in a
function. Forbidden by my ++ suggestion.
Do you want to add a warning in FriCAS book in section describing
declarations that one should initialize variables before use?
Yes, why not. We all know that there is a difference between a FriCAS
(programming) variable and a variable (i.e. something that evaluates to
itself). In traditional CAS that's not totally easy to understand for a
first time user.
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 fricas-devel+unsubscr...@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/fricas-devel/1afe4a05-d804-42ca-802f-6f813f6501eb%40hemmecke.org.