Design #1538
RingElem from string (ReadExpr)
Description
What should the following do
RingElem(QQ, "1/-2");
Currently it gives error "unexpected minus".
Related issues
History
#1 Updated by John Abbott over 3 years ago
- Related to Design #1529: INPUT questions added
#2 Updated by John Abbott over 3 years ago
Similar problem for RingElem(QQ, "2*-3");
#3 Updated by John Abbott over 3 years ago
My personal opinion is that I do not like 1/-2
and 2*-3
; they both look like typos to me. Perhaps the user meant 1/x-2
or 2*x-3
?
In contrast, with brackets I find it easier to read, and less likely that the user made a typo.
#4 Updated by John Abbott over 3 years ago
- Related to Bug #1537: EmacUI: strange colours, sometimes added
#5 Updated by John Abbott over 3 years ago
- Status changed from New to In Progress
- % Done changed from 0 to 10
The input functions are quite messy: not really a coherent design philosophy.
It seems that ReadExpr
gives error if there are extra chars after the end of the expr, but ReadExprSemicolon
does not complain if there are extra chars after the semicolon.
At the moment my expectation is that a fn which accepts a stream would read the next item on the stream, and leave the input pointer at the first char after the read value.
If the caller wants to ensure that there is nothing else in the stream then this must be written explicitly in the caller's code.
With this design ReadExprSemicolon
becomes even simpler to implement.
Maybe there could be ReadJust1Expr
which behaves as ReadExpr
currently does?
#6 Updated by John Abbott over 3 years ago
- Related to Design #1540: Double power added
#7 Updated by John Abbott about 3 years ago
- Status changed from In Progress to Resolved
- Assignee set to John Abbott
- % Done changed from 10 to 70
The current impl is:
- reading from
istream
keeps going until an "impossible" char is found; error if expr up to that point is incomplete, o/w no error & remaining chars are ready for further input operations - reading from
string
expects the string to contain exactly the right input: trailing non-whitespace chars will trigger an error
#8 Updated by John Abbott about 3 years ago
- % Done changed from 70 to 80
I have changed the CoCoA-5 parser so that it produces a warning when given input such as 2*-1
or 3/-1
. The computation still works, but the warning recomments putting the 2nd arg inside brackets. Also 2*+1
and 3/+1
produce the same warning.
An impromptu test suggests that all works as desired.
#9 Updated by John Abbott about 3 years ago
Should we attempt to produce a better error message for the example given in the original description?
Is it worth it? Is that a good use of our limited resources?
#10 Updated by John Abbott about 3 years ago
- Related to Bug #1579: Readexpr/RingElem: unhelpful error message when input is wrong added
#11 Updated by John Abbott over 2 years ago
- Status changed from Resolved to Closed
- % Done changed from 80 to 100
- Estimated time set to 1.61 h
#12 Updated by Anna Maria Bigatti 12 months ago
- Related to Slug #1518: SLUG: Printing PPs with many indets added