Project

General

Profile

Design #525

BuiltInFunctions: evalArgAsT1OrT2, evalArgAsT1OrT2OrT3, ... last argument

Added by Anna Maria Bigatti about 10 years ago. Updated over 9 years ago.

Status:
Closed
Priority:
Normal
Category:
Cleaning
Target version:
Start date:
08 Apr 2014
Due date:
% Done:

100%

Estimated time:
2.50 h
Spent time:

Description

the functions EvalArgAsT1OrT2OrT3... modify the last argument (int) giving 1 or 2 or 3...
the functions EvalArgAsT1OrT2 modifies the last argument (bool) giving isFirst

Should we change EvalArgAsT1OrT2 so that it behaves like the others?
It would be a good idea, but it is extremely delicate work because of silent conversions between int and bool.

2014-08 done: last arg in all functions now is int (usually called which)


Related issues

Related to CoCoA-5 - Feature #384: IsZero for matrixClosed2013-07-05

Related to CoCoA-5 - Support #296: Documentation for Parser/InterpreterIn Progress2013-01-24

Related to CoCoA-5 - Design #294: BuiltInFunctions: General "OneLiner" for arguments of different typeClosed2013-01-23

Related to CoCoALib - Support #452: Documentation for adding functions to CoCoA-5 (BuiltInFunctions and BuiltInOneLiners)Closed2014-03-01

History

#1 Updated by John Abbott about 10 years ago

I like the idea of making them all "compatible".

Another option would be to have an enum with one value for each type, and the function returns the enum value corresponding to the type actually found. This would make the order of the types in the template irrelevant:

TypeEnum ActualType;
auto arg1 = EvalAsT1OrT2OrT3<BigInt, BigRat, RingElem>(ARG(1), ActualType);
switch (ActualType)
{
  case BigIntType: ...
  case BigRatType: ...
  case RingElemType: ...
}

I don't guarantee that this could be realised...

#2 Updated by Anna Maria Bigatti almost 10 years ago

  • Subject changed from BuiltInFunctions: EvalArgAsT1OrT2 to BuiltInFunctions: evalArgAsT1OrT2
  • Category changed from Parser/Interpreter to Cleaning
  • Status changed from New to Resolved
  • Assignee set to Anna Maria Bigatti
  • % Done changed from 0 to 80

We agreed that it would be handy to have the same interface for
evalArgAsT1orT2 and evalArgAsT1orT2orT3.
The last argument of evalArgAsT1orT2 is the bool isT1, whereas in the new view it should be an int which: this is the situation
isT1=true would give which=1, that is T1
isT1=false would give which=0, that is invalid, but it usually used as !isT1, that is T2.
HOWEVER I left a non-implemented version with bool so that passing bool instead of int would not link.
All done: it works

#3 Updated by Anna Maria Bigatti almost 10 years ago

  • Status changed from Resolved to Feedback
  • % Done changed from 80 to 90

cvs-ed

#4 Updated by Anna Maria Bigatti over 9 years ago

  • Tracker changed from Bug to Design
  • Subject changed from BuiltInFunctions: evalArgAsT1OrT2 to BuiltInFunctions: evalArgAsT1OrT2, evalArgAsT1OrT2OrT3, ... last argument
  • Status changed from Feedback to Closed
  • % Done changed from 90 to 100

Also available in: Atom PDF