Arc Forumnew | comments | leaders | submitlogin
The Dark side of Symbols
2 points by conanite 5187 days ago | 3 comments
42 days after http://www.arclanguage.org/item?id=12269 , I'm happy to report that rainbow's symbols are (almost) up to spec.

rocketnia reported

  Both Jarc 17 and Rainbow think the name of '|.| is "|.|" rather than "."
It was much worse: rainbow didn't handle symbols enclosed in pipe characters at all, except for the special case of '|| (which was necessary for news.arc).

It seems that the rule is that anything that could be interpreted as a number, or containing improper characters ["'#; \n\t], needs to be enclosed in pipes.

Rainbow expects the pipe characters at the beginning and end of the symbol. Scheme is a bit wilder: it accepts them anywhere, as often as you want; they are only required to enclose the offending bit of the symbol. In other words,

  foo|#|bar
is the same as

  |foo#bar|
and

  |"|foo||bar|"|
is dbl-quote, followed by 'foo, followed by emptiness, followed by 'bar, followed by dbl-quote again, and is thus the same as

  |"foobar"|
So rainbow only understands |"foobar"|, where pipes delimit the entire symbol, and doesn't read the scheme symbol syntax in all its hairiness. Another missing piece was that rainbow produced the same output for (write sym) and (disp sym); fixed.

Many thanks, rocketnia, and I'm working on your other bug reports too, keep 'em coming :)

Here are the new test cases for this issue:

  (tostring:write (coerce "foo\nbar" 'sym))
  "|foo
  bar|"

  (tostring:disp (coerce "foo\nbar" 'sym))
  "foo
  bar"

  (tostring:write '|foo;bar|)
  "|foo;bar|"

  (tostring:disp '|foo;bar|)
  "foo;bar"

  (tostring:write '||)
  "||"

  (tostring:disp '||)
  ""

  (tostring:write '|.|)
  "|.|"

  (tostring:disp '|.|)
  "."

  (coerce "21" 'sym)
  |21|

  (coerce "1.23E10" 'sym)
  |1.23E10|

  (coerce ";" 'sym)
  |;|

  (coerce "+nan.0" 'sym)
  |+nan.0|

  (coerce "|foo|" 'sym)
  \|foo\|

  (coerce "(foo)" 'sym)
  |(foo)|


  (tostring:write (coerce "|foo|" 'sym))
  "\\|foo\\|"

  (tostring:disp (coerce "|foo|" 'sym))
  "|foo|"

  (coerce "\"foo\"" 'sym)
  |"foo"|

  (coerce "'" 'sym)
  |'|

  (coerce "||||||||||||||" 'sym)
  \|\|\|\|\|\|\|\|\|\|\|\|\|\|

  (coerce (coerce "" 'sym) 'string)
  ""
The above available as usual at http://github.com/conanite/rainbow


3 points by aw 5187 days ago | link

and doesn't read the scheme symbol syntax in all its hairiness

I agree with this decision; it's useful to be able to write an arbitrary symbol and have it read back in again as the same symbol from that canonical representation; but we don't need to support every Scheme feature that happens to be visible from Arc...

-----

2 points by rocketnia 5187 days ago | link

we don't need to support every Scheme feature that happens to be visible from Arc...

I agree with that as a principle, but I do sometimes get carried away in my bug reports. ^_^

-----

1 point by jazzdev 5157 days ago | link

Wow, it's dark twisty passages all the way down.

More for the Jarc To-Do list. I can see Jarc has only begun to scratch the surface on escaped symbols.

-----