Difference between revisions of "CoCoA:CoCoA4Language Issues"

From ApCoCoAWiki
(add BigInt vs. Int, ForLoop oddness and F (x+y) vs. F(x+y);)
 
Line 7: Line 7:
 
==F (x+y); vs. F(x+y);==
 
==F (x+y); vs. F(x+y);==
  
Imagine the follwing 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?
+
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=
 
=Problems with the implementation in CoCoA 4.X=

Revision as of 13:17, 31 March 2006

Introduction

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 folling code:

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

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 incrementin 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
  PrintLn(I);
EndFor;

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

ERROR: Cannot cast to INT (integer too big)