'default' in Interpreter

3 views
Skip to first unread message

Grégory Vanuxem

unread,
Oct 31, 2024, 3:10:05 PM10/31/24
to fricas...@googlegroups.com
Hello,

I have some issues with the 'default' keyword (?) in the interpreter,
I need it to coerce it to a JuliaSymbol, but coercing 'default to a
JuliaSymbol is not possible unless I use it as a string:

(2) -> a:=necf(1/2);
(3) -> sin(a,'tangent)

(3) 0.479426 {(2*a)/(a^2+1) where a = 0.255342 [Tan(0.250000 {1/4})]}

Type: NemoExactComplexField
(4) -> sin(a,'exponential)

(4)
0.479426 + 0e-24*I {(-a^2*b+b)/(2*a) where a = 0.877583 + 0.479426*I
[Exp(0.500000*I {(b)/2})], b = I [b^2+1=0
]}

Type: NemoExactComplexField
(5) -> sin(a,'default)
Line 1: sin(a,'default)
......A
Error A: syntax error at top level
Error A: Improper syntax.
2 error(s) parsing

(5) -> sin(a,"default")

(5)
0.479426 + 0e-24*I {(-a^2*b+b)/(2*a) where a = 0.877583 + 0.479426*I
[Exp(0.500000*I {(b)/2})], b = I [b^2+1=0
]}

And if I issue, even in the official FriCAS, 'default' in the interpreter:

(6) -> default
Internal Error
Unexpected error in call to system function pf2Sex1

So I wonder why, and if it can be filtered somewhere in boot or Lisp
code? Also, if it can be and if it will be, what about doing like
Julia or Xcas when they avoid defining an already defined symbol like
'sin' for example? In FriCAS it is possible to assign to a variable,
say 'sin' for example, something like:

sin := sin(0.5)

After, the sin function is no longer available by default. I think it
should be possible during an assignment to check if 'sin' is already a
library operation, something like defined?(Symbol) in the interpreter
code.

In Julia:

julia> sin=sin(0.7)
ERROR: cannot assign a value to imported variable Base.sin from module Main
Stacktrace:
[1] top-level scope
@ REPL[1]:1

Xcas:
sin:=sin(0.5)
=> sin' is a reserved word, sto not allowed: 0.479425538604

Python allows this though, as FriCAS:

Python 3.12.6 (main, Sep 7 2024, 14:20:15) [GCC 14.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from math import sin
>>> sin=sin(0.5)
>>> sin(1.7)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'float' object is not callable
>>>

My primary interest is of course 'default', after, it is a matter of
taste I think.

- Greg

Waldek Hebisch

unread,
Oct 31, 2024, 3:31:09 PM10/31/24
to fricas...@googlegroups.com
On Thu, Oct 31, 2024 at 08:09:24PM +0100, Grégory Vanuxem wrote:
> Hello,
>
> I have some issues with the 'default' keyword (?) in the interpreter,
> I need it to coerce it to a JuliaSymbol, but coercing 'default to a
> JuliaSymbol is not possible unless I use it as a string:

'default' is a reserved word, like 'if' and 'else'. Currently it
is not used in interpreter or Spad compiler. It is used in Aldor
and reserved for compatibility.

--
Waldek Hebisch

Grégory Vanuxem

unread,
Oct 31, 2024, 3:36:43 PM10/31/24
to fricas...@googlegroups.com
Ah, ok, thanks. I guess it is used in struct like switch, case… in other languages. I will quickly look at the Aldor documentation.


--
                              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...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/fricas-devel/ZyPa-pGAO3FRKKij%40fricas.org.
Reply all
Reply to author
Forward
0 new messages