why is there no end if in Fricas?

12 views
Skip to first unread message

Nasser M. Abbasi

unread,
Dec 7, 2021, 9:03:46 AM12/7/21
to FriCAS - computer algebra system
I was looking at https://fricas.github.io/book.pdf and on page 149  it gives examples of what it calls pile programming

   if h > 3.1 then
        1.0
   else
        z := cos (h)
        max (z ,0.5)

So there is no end if in Fricas? Similar thing I noticed in other constructs. There is no explicit end.

It seems Fricas is similar to Python in this, in that it uses spaces and indentations for when a construct end.

I do not like this myself. I think having an explicit end make the code and the algorithm more clear, instead of just depending on using spaces.

I know very little about programming in Fricas. Is this the only mode of programming in Fricas?   Why not have an explicit end? Was this a choice made long time ago for the Fricas language? 



  

Ralf Hemmecke

unread,
Dec 7, 2021, 9:56:53 AM12/7/21
to fricas...@googlegroups.com
> It seems Fricas is similar to Python in this, in that it uses spaces and
> indentations for when a construct end.

Right.
> I do not like this myself. I think having an explicit *end* make the code
> and the algorithm more clear, instead of just depending on using spaces.

I am actually on your side and used C-style coding in Aldor (which was
invented to become the new compiler in AXIOM when AXIOM was still a
commercial product, but unfortunately never made it into the system. So
the situation now is that we have to live with what we have in FriCAS.

> I know very little about programming in Fricas. Is this the only mode of
> programming in Fricas? Why not have an explicit end? Was this a choice
> made long time ago for the Fricas language?

The closest you can get is to enclose code blocks in parentheses and
separate command by ; (semicolon).

if h > 3.1 then 1.0 else (z := cos(h); max (z ,0.5))

I don't think that it is much better with parentheses.
You will soon get along with pile mode if you exercise programming a bit.

Ralf
Reply all
Reply to author
Forward
0 new messages