Bug #878
RingElem applied to a symbol (repr as a string)
Description
The current design for converting a symbol (repr as a string) into a RINGELEM is inconvenient.
I wanted to do this while demo-ing CoCoA-5 and ended up being rather confused.
The function RingElem
works only for symbols without indices; if there are indices then they must be specified using a rather unnatural and awkward syntax e.g. RingElem(P, ["a", 2])
to get a[2]
.
The call RingElem(P,"a[2]")
produces the unhelpful/misleading error "illegal symbol head".
In contrast, the function ReadExpr(P, "a[2]")
does work.
Related issues
History
#1 Updated by John Abbott almost 8 years ago
Personally I find the situation described quite confusing.
It is not clear to me why ReadExpr
is not already included in RingElem
.
#2 Updated by John Abbott almost 8 years ago
- Related to Feature #606: Evaluate in ring operator (was called :: in CoCoA-4) added
#3 Updated by John Abbott almost 7 years ago
- Related to Design #1051: ReadExpr(P, string) and RingElem(P, string) added
#4 Updated by Anna Maria Bigatti almost 7 years ago
- Assignee set to Anna Maria Bigatti
- Target version changed from CoCoA-5.?.? to CoCoA-5.2.0 spring 2017
- % Done changed from 0 to 90
Fixed, now calls ReadExpr
.
Documented.
I kept the syntax RingElem(P, ["a", i])
because it allows variable indices.
Not sure how useful this really is, but it works.
#5 Updated by John Abbott almost 7 years ago
- Status changed from New to Resolved
- Estimated time set to 1.80 h
As already indicated in the description, I do not much like the awkward syntax RingElem(P, ["a",i])
.
I do see the potential utility of being able to specify the indices as values of variables, and surely RingElem(P, "a["+sprint(i)+"]")
is even worse than the "awkward syntax".
What about RingElem(P, "a", [i])
? Or we could even do RingElem(P, symbol("a",i))
where symbol
in CoCoA-5 could just return the string "a[" + sprint(i) + "]"
Or should we just wait until the function is really needed? The sprint
solution can be used by anyone...
#6 Updated by Anna Maria Bigatti almost 7 years ago
John Abbott wrote:
Or should we just wait until the function is really needed? The
sprint
solution can be used by anyone...
I do not think it is of any use, now that we can use sprint.
And I think it's NOT worth thinking about it.
But I do not feel like gratuituosly remove it or change it.
#7 Updated by Anna Maria Bigatti almost 7 years ago
- Status changed from Resolved to Closed
- % Done changed from 90 to 100