Project

General

Profile

Feature #317

BuiltInFunctions: evalArgAsLong

Added by Anna Maria Bigatti about 11 years ago. Updated over 8 years ago.

Status:
Closed
Priority:
Normal
Category:
Parser/Interpreter
Start date:
20 Feb 2013
Due date:
% Done:

100%

Estimated time:
3.01 h
Spent time:

Description

Similar to evalArgAsListOf or VectorLong (or VectorLongDecr1) it would be nice to have
a way of converting a BigInt into a long with a suitable error message from the interpreter.
(readability in BuiltinFunctions would improve)

We should also reconsider all the names since some returns intrusive_ptr<type> and others a (vector of) type.


Related issues

Related to CoCoALib - Feature #426: ConvertTo with optional arg to give more helpful error messageClosed2014-01-27

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

History

#1 Updated by Anna Maria Bigatti about 11 years ago

There are lots of lines like (in BuiltinFunctions.C and Interpreter.C)

long l;
if (!IsConvertible(l, N->theInteger))
  throw RuntimeException("....", indexExpBegin, indexExpEnd);

or
  throw RuntimeException("....", ARG(0).exp);

Understand the types involved and find a good name for the function.

#2 Updated by Anna Maria Bigatti over 10 years ago

  • Target version changed from CoCoA-5.0.9 to CoCoA-5.1.0 Easter14

#3 Updated by Anna Maria Bigatti about 10 years ago

  • Subject changed from EvalArgAsLong ? to BuiltInFunctions: EvalArgAsLong ?

#4 Updated by John Abbott about 10 years ago

  • Target version changed from CoCoA-5.1.0 Easter14 to CoCoA-5.1.1 Seoul14

#5 Updated by John Abbott over 9 years ago

  • Target version changed from CoCoA-5.1.1 Seoul14 to CoCoA-5.1.2 summer 2015

#6 Updated by Anna Maria Bigatti almost 9 years ago

  • Assignee set to Anna Maria Bigatti
  • % Done changed from 0 to 40
  • Estimated time set to 2.00 h

I have implemented in Interpreter.C the function evalArgAsLong returning a long.
I tested it on the definition of RandomSubsetIndices and it looks nice: expressive, handy, and gives the correct position in case of non-convertible integer.
The error message is number is too big. Should we change it? (Interpreter.C)

#7 Updated by Anna Maria Bigatti almost 9 years ago

  • Subject changed from BuiltInFunctions: EvalArgAsLong ? to BuiltInFunctions: evalArgAsLong
  • Status changed from New to Resolved

#8 Updated by Anna Maria Bigatti almost 9 years ago

... I liked it so much I also changed RandomTupleIndices, IsZeroRow, IsZeroCol.
The code becomes shorter and easier to write (compared with ConvertTo<long>).
Moreover the error message gives the position of the argument.

#9 Updated by Anna Maria Bigatti almost 9 years ago

  • Estimated time changed from 2.00 h to 2.50 h

#10 Updated by Anna Maria Bigatti over 8 years ago

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

We should also reconsider all the names since some returns intrusive_ptr<type> and others a (vector of) type.

Now I think it is OK (might be confusing, but not ambiguous ;-):
evalArgAs<type> returns intrusive_ptr<type>
evalArgAsType returns type

I changed essentially all IsConvertible into evalArgAsLong in BuiltInFunctions.C

#11 Updated by Anna Maria Bigatti over 8 years ago

  • Status changed from Feedback to Closed
  • % Done changed from 80 to 100
  • Estimated time changed from 2.50 h to 3.01 h

Also available in: Atom PDF