Project

General

Profile

Design #1508

Initial ring

Added by John Abbott over 3 years ago. Updated about 2 months ago.

Status:
In Progress
Priority:
Normal
Assignee:
-
Category:
enhancing/improving
Target version:
Start date:
13 Oct 2020
Due date:
% Done:

50%

Estimated time:
Spent time:

Description

After lunch with Robbiano today...
The question of the initial ring in CoCoA-5 came up. There are two proposals to consider:
  • (A) Right after the banner print a message saying what the current ring is;
  • (B) start with no current ring, so the user is forced to set it.

Thoughts? Opinions?

History

#1 Updated by John Abbott over 3 years ago

I'm not entirely sure how to achieve technically "start with no current ring":
  • (1) use an extra flag to say no ring has been set
  • (2) set a "strange" initial ring (e.g. ZZ)

#2 Updated by John Abbott over 3 years ago

The technically easiest solution would be start with the ring ZZ; while not exactly what was suggested, I suspect that it would work well. We could also use QQ, which also has no indeterminates.

An important point is that such a change would break backward compatibility.

We could implement a flag saying which ring to use upon start-up (i.e. choosing between ZZ and the current choice, namely QQ[x,y,z])
A possible name for the flag is --use-QQxyz.

#3 Updated by John Abbott over 3 years ago

  • Status changed from New to In Progress
  • % Done changed from 0 to 10

A relevant line in the source code is Interpreter.C:1212 which contains:

this->setTopLevelVar("R", new RING(NewPolyRing(RingQQ(),symbols("x,y,z"))), VariableSlot::VSF_None);

I removed use R from init.cocoa5, and indeed CurrentRing then returns nothing (presumably NULL). I think I'd feel easier with having ZZ or QQ as the initial ring (rather than nothing at all).

#4 Updated by Anna Maria Bigatti over 3 years ago

  • % Done changed from 10 to 20

I vote for (A) Right after the banner print a message saying what the current ring is

Cleanliness would demand having no initial ring, and indeed CoCoALib has no "CurrentRing".

However, for CoCoA5, I much prefer having an initial ring ready available for two reasons.
1. for the beginner: experience says people don't read the manual, especially when using a program for the first time. We don't want to put them off
2. for all those little computations one user (like me) may run on the fly.

I understand that some user might forget to set his ring "R", and then use the predefined "R", leading to unexpected behaviour.

So my suggestion is:
  1. leave the initial current ring as is, activated in init.cocoa5
  2. give it an awkward/explanatory name, like QQxyz_StartingRing, instead of R
  3. possibly, add a flag for those who want CoCoA to start clean (but I'm not in that list!)

#5 Updated by John Abbott over 3 years ago

I like Anna's suggestions:
  • by default start with the initial ring QQ[x,y,z] (why should it be assigned to a variable?)
  • have a start-up flag to say to start without an initial ring
  • if we want the initial ring to be in a variable, how about CoCoAInitialRing? Or perhaps CoCoA_Initial_Ring?

There is an important technical point: currently the initial ring is set by the line use R; in the file init.cocoa5.
The changes above require that the initial ring be set by C++ code; finding what changes to the code are needed may be non trivial :-/

#6 Updated by John Abbott over 3 years ago

Presumably the CoCoA-5 interpreter has a function which performs the command source. If this function can accept an istream then we could just create a string containing "use CoCoAInitialRing;", and then pass an istringstream to the code for executing the source command. This is a short-cut (and avoids having to create a special init file).

HINT: relevant part of Interpreter.C seems to be SourceStatement::implExecute(RuntimeEnvironment *runtimeEnv) around line 4030
PS does not look easy to use as I had hoped :-(

#7 Updated by John Abbott over 2 years ago

  • Target version changed from CoCoA-5.4.0 to CoCoA-5.4.2

#8 Updated by John Abbott about 2 months ago

  • % Done changed from 20 to 50
This issue has been dormant for too long. Here is what I now think:
  • the initial ring should have a longer name, I like QQxyz (and do not really see the advantage of the rather longer QQxyz_InitialRing*)
  • the initial ring appears to be set inside the package init.cocoa5 which is not user modifiable if CoCoA is system-wide installed; this package could print out the short message saying what the initial ring is
  • there used to be the possibility of each user having a userinit.coc file -- should we reactive this (in some form?)

We can start cocoa5 with a flag to suppress printing of the banner; not sure how to use that the suppress printing of the initial ring (not even sure whether we would want to do that).

KISS: change the name in line 1229 of Interpreter.C, and change also the package init.cocoa5 so it uses the new name, and also prints out a short message saying what the initial ring is.

NOTE: there must be a pre-initial ring before the use line in init.cocoa5 is executed; presumably this must be ZZ or QQ since no other rings exist at the start.

#9 Updated by Anna Maria Bigatti about 2 months ago

I'm undecided about changing the name (some beginner user might think that the name "QQxyz" has some interpretation by CoCoA)

Let's say we call il "P", as we usually do now, I would add the line in the banner

CurrentRing is  P ::= QQ[x,y,z];

This could help a beginner user in changing it, if he needs it.

#10 Updated by John Abbott about 2 months ago

(1) I modified packages/init.cocoa5 so that it prints out a message about the initial ring.
This was a bad idea: it meant that all the CoCoA-5 tests obtained an unexpected extra line the output (despite --no-banner).
Also the printed string is a constant (since otherwise the ring prints less comprehensibly), but the definition of the ring is
elsewhere -- so I put a comment into init.cocoa5

(2) I removed the print from init.cocoa5 and appended to the string produced by CoCoA5Banner in file Banner.C
I added another comment to init.cocoa5 indicating that the announcement of the initial ring is in Banner.C
I added a comment to the "print" string in CoCoA5Banner indicating where the initial ring is defined.
All CoCoA-5 tests pass (except exsegv.cocoa5 which incorrectly tried to access the ring R -- corrected)

(3) Should init.cocoa5 be removed? It does practically nothing (just use P;). I suspect it was kept for "backward compatibility"
reasons (but userinit.coc was not preserved... very odd!)

#11 Updated by John Abbott about 2 months ago

The actual message is

Initial CurrentRing is  P ::= QQ[x,y,z];

Also available in: Atom PDF