metaeducation / rebol-issues

6 stars 1 forks source link

reflexivity: MOLD/ALL and LOAD incompatible for "short" paths #1947

Open rebolbot opened 11 years ago

rebolbot commented 11 years ago

Submitted by: Ladislav

MOLD/ALL and LOAD are incompatible for "short" paths, as the following tests reveal (in every test, TRUE is expected as the result)

This harms reflexivity of Rebol.

; empty path test, TRUE expected
any [
    error? try [make path! []]
    equal? make path! [] load mold/all make path! []
]
** Syntax error: invalid constructor: [path! []]
** Where: to case load any catch either -apply- do

; one-element path test, TRUE expected
any [
    error? try [make path! [a]]
    equal? make path! [a] load mold/all make path! [a]
] ; == none

; empty lit-path test, TRUE expected
any [
    error? try [make lit-path! []]
    equal? make lit-path! [] load mold/all make lit-path! []
]
** Syntax error: invalid constructor: [lit-path! []]
** Where: to case load any catch either -apply- do

; one-element lit-path test, TRUE expected
any [
    error? try [make lit-path! [a]]
    equal? make lit-path! [a] load mold/all make lit-path! [a]
] ; == none

; empty get-path test, TRUE expected
any [
    error? try [make get-path! []]
    equal? make get-path! [] load mold/all make get-path! []
]
** Syntax error: invalid constructor: [get-path! []]
** Where: to case load any catch either -apply- do

; one-element get-path test, TRUE expected
any [
    error? try [make get-path! [a]]
    equal? make get-path! [a] load mold/all make get-path! [a]
] ; == none

; empty set-path test, TRUE expected
any [
    error? try [make set-path! []]
    equal? make set-path! [] load mold/all make set-path! []
]
** Syntax error: invalid constructor: [set-path! []]
** Where: to case load any catch either -apply- do

; one-element set-path test, TRUE expected
any [
    error? try [make set-path! [a]]
    equal? make set-path! [a] load mold/all make set-path! [a]
] ; == none

CC - Data [ Version: r3 master Type: Bug Platform: All Category: Datatype Reproduce: Always Fixed-in:none ]

rebolbot commented 11 years ago

Submitted by: BrianH

Noticed that the path types didn't work with the constructor ("serialized") syntax when going over the tests. We need to change those tests so they apply to R3. R3 needs those constructors.

As for MOLD/all, having it generate constructor syntax when the path wouldn't parse is a good idea, if that can be determinable without too much overhead. If the overhead is too great, then have MOLD/all do the constructor syntax every time.

Cases where constructor syntax would be needed:

- Paths of less than 2 elements
- Paths with offset positions
- Paths containing elements that would also need constructor syntax
- Paths containing elements that don't parse correctly in normal path syntax

If these tests can be done efficiently enough, we might want to add them to normal MOLD and generate constructor syntax there too. That needs some debate though.

rebolbot commented 11 years ago

Submitted by: BrianH

I noticed that you removed the constructor syntax tests for paths, replacing them with reflexivity tests. We need to restore the constructor syntax tests, since the existence and behavior of such syntax also needs to be tested for. Reflexivity is nice, but how we achieve such reflexivity is equally important, or perhaps more so.