R3's PARSE currently has a nasty regression in the handling of case-sensitivity for bitsets/charsets.
In R2, bitsets where always treated case-sensitively, irrespective of whether we used PARSE/case (see the first section of the example code).
In R3, bitsets are currently treated case-sensitively without /case, but case-insensitively with /case, effectively inverting the desired meaning of the /case refinement (see the second section of the example code).
The current behaviour of R3 is unacceptable: /CASE is used to indicate that case-sensitive comparison is to be used, but the current implementation does the complete opposite.
See the comments for a discussion of possible solutions.
This issue was originally reported by HostileFork on StackOverflow Chat.
; --- R2 Example Code ---
R2>> parse "a" reduce [charset "a"]
R2== true
R2>> parse/case "a" reduce [charset "a"]
R2== true
R2>> parse "A" reduce [charset "a"]
R2== false
R2>> parse/case "A" reduce [charset "a"]
R2== false
; --- R3 Example Code ---
R3>> parse "a" reduce [charset "a"]
R3== true ; OK
R3>> parse/case "a" reduce [charset "a"]
R3== true ; OK
R3>> parse "A" reduce [charset "a"]
R3== false ; Debatable
R3>> parse/case "A" reduce [charset "a"]
R3== true ; Unacceptable
(A) Fix this thoroughly by making bitsets behaviour consistent with the /case flag:
- without /case, bitsets are treated case-insensitively by PARSE;
- with /case, bitsets are treated case-sensitively by PARSE.
(B) Fix this issue by falling back to R2's behaviour: with or without /case, bitsets are always treated case-sensitively by PARSE.
Of those two solutions, I would prefer (A) for the sake of improved consistency and predictability. I think that there are enough PARSE incompatibilities between R2 and R3 already, so that it's not worth to hold back with fixing this issue properly in the name of backwards-compatibility.
Rebolbot commented on Jan 20, 2013:
Submitted by:abolka
HostileFork submitted a fix implementing (A) as proposed above as pull request 63:
https://github.com/rebol/r3/pull/63
Rebolbot commented on Jan 20, 2013:
Submitted by:BrianH
Fork's approach (A) seems to be the best here. See #666 for R2 compatibility issues.
Rebolbot commented on Jan 21, 2013:
Submitted by:abolka
A quick poll on AltME has so far resulted in 3 further votes in favour of A (Gregg, Ladislav, Robert).
Rebolbot commented on Jan 22, 2013:
Submitted by:abolka
A fix implementing variant (A) has been merged in 6292a2f61b1fe37edbdc17cf61904290cf0a0c3b.
Submitted by: abolka
R3's PARSE currently has a nasty regression in the handling of case-sensitivity for bitsets/charsets.
In R2, bitsets where always treated case-sensitively, irrespective of whether we used PARSE/case (see the first section of the example code).
In R3, bitsets are currently treated case-sensitively without /case, but case-insensitively with /case, effectively inverting the desired meaning of the /case refinement (see the second section of the example code).
The current behaviour of R3 is unacceptable: /CASE is used to indicate that case-sensitive comparison is to be used, but the current implementation does the complete opposite.
See the comments for a discussion of possible solutions.
This issue was originally reported by HostileFork on StackOverflow Chat.
Imported from: CureCode [ Version: alpha 111 Type: Bug Platform: All Category: Parse Reproduce: Always Fixed-in:r3 master ] Imported from: https://github.com/rebol/rebol-issues/issues/1938
Comments:
Submitted by: abolka
I currently see two possible solutions:
Of those two solutions, I would prefer (A) for the sake of improved consistency and predictability. I think that there are enough PARSE incompatibilities between R2 and R3 already, so that it's not worth to hold back with fixing this issue properly in the name of backwards-compatibility.
Submitted by: abolka
HostileFork submitted a fix implementing (A) as proposed above as pull request 63:
Submitted by: BrianH
Fork's approach (A) seems to be the best here. See #666 for R2 compatibility issues.
Submitted by: abolka
A quick poll on AltME has so far resulted in 3 further votes in favour of A (Gregg, Ladislav, Robert).
Submitted by: abolka
A fix implementing variant (A) has been merged in 6292a2f61b1fe37edbdc17cf61904290cf0a0c3b.