gracelang / minigrace

Self-hosting compiler for the Grace programming language
39 stars 22 forks source link

asString methods on ranges and sequences differ #334

Closed apblack closed 1 year ago

apblack commented 1 year ago

Ranges and Sequences are two implementations of the same type. Minigrace takes care that, for example,

(1..4) == [1,2,3,4]
(4..1) == []

they compare equal, have the same hash, and so on.

However, as noted in this issue, their asString methods give different results. This is wrong.

apblack commented 1 year ago

This issue is fixed in commit 602672c. The asDebugString methods still do produce different strings, but that's correct, because asDebugString is intended to reveal the implementation.

print (1..4)                     // => [1, 2, 3, 4]
print ((1..4).asDebugString)     // => range.from 1 to 4
print [1,2,3,4]                  // => [1, 2, 3, 4]
print ([1,2,3,4].asDebugString)  // => sequence [1, 2, 3, 4]