On Tue, Jul 10, 2018 at 11:51 AM, Riccardo GUIDA
<riccardo.gu...@gmail.com> wrote:
>
> Command line interpreter: I realize that type declaration is ignored
> in delayed assignment == even for variables (see [1] for a similar
> behavior for functions)
>
> Same behavior from .input file.
>

Although this terminology is used in a few places, I do not think it
is correct to call == delayed assignment. Rather it only represents
kind of function definition via matching (which granted, does involve
some form of delayed assignment). More specifically in the interpreter
== defines a "rule". In the case of ==, : is an operator like any
other. E.g.

(1) -> (x+y) == 3
                                                                   Type: Void
(2) -> (x:Integer) == 4
                                                                   Type: Void
(3) -> )display value +
   Definition:   + (x, y) == 3
(3) -> )display value :
   Definition:   : (x, Integer) == 4
(3) -> x+y
   Compiling function + with type (Variable(x), Variable(y)) ->
      PositiveInteger

   (3)  3
                                                        Type: PositiveInteger
(4) -> x:Integer
                                                                   Type: Void

Only the last result is a bit anomalous. One might have expected the
value 4 but without the == the interpreter is treating this like a
declaration rather than an expression.

As illustrated in the users guide, this sort of matching in the
interpreter is useful for defining functions by cases etc. But I think
it can produce rather surprising and unexpected effects. E.g.

(4) -> 1+1 == 3
                                                                   Type: Void
(5) -> 1+1
   Compiling function + with type (PositiveInteger, PositiveInteger)
       -> PositiveInteger

   (5)  3
                                                        Type: PositiveInteger

(6) -> 1+2

   The function + is not defined for the given argument(s).

This is very unlike the semantics implemented implemented in the
library compiler.  In spite of this, the interpreter does otherwise
manage to interface with the FriCAS library quite well.

-- 
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 post to this group, send email to fricas-devel@googlegroups.com.
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