CoCoA:CoCoA4Language Issues

From ApCoCoAWiki
Revision as of 15:20, 16 October 2007 by Dheldt (talk | contribs) (CoCoA5Language:CoCoA4Language Issues moved to CoCoA:CoCoA4Language Issues: tidying up the wiki.)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)


This page lists a number of issues that are either ambiguous or limitations in the language of CoCoA4 itself. As we implement the new CoCoA5Client this page is sure to grow larger.

Problems with ambiguity in the language in CoCoA 4.X

F (x+y); vs. F(x+y);

Imagine the following situation: You define a function F and also a variable F that contains a polynomial. What should CoCoA do when encountering the two constructs from above?

Problems with the implementation in CoCoA 4.X

Variable in for loops

Take a look at the following code:

For I:=1 To 4 Do
  Print "Before ", I;
  I:= I+1;
  Println " - After: ", I;

You would expect that the change to the variable I in the body of the for-loop would be permanent, i.e. the number of iterations in the for-loop would be halved by incrementing I by one in each iteration. Alas, the output from CoCoA 4.X results in

Before 1 - After: 2
Before 2 - After: 3
Before 3 - After: 4
Before 4 - After: 5

This should not happen.

BigInt vs. Int

In some situations in the interpreter of CoCoA 4.X we are limited by the use of integers when parsing parameters, i.e. the range operator ".." will currently fail when feeding the following statement to CoCoA 4.X:

L:= 2^32..2^32+3;

Another place where this happens is inside for-loops, when start or stop value exceed max-int. i.e.

For I:=2^32 To 2^32+3 Do

The error returned by CoCoA 4.X in that case is

ERROR: Cannot cast to INT (integer too big)

Size(List) returns length of list

Size should return the size of an object in bytes. When applied to lists Size returns the length of the list.