Oldes / Rebol-wishes

Repository for keeping Rebol related wishes out of issues
0 stars 0 forks source link

Change behavior of TO-STRING to replace FORM, add SPELLING functions #27

Open Siskin-Bot opened 4 years ago

Siskin-Bot commented 4 years ago

Submitted by: fork

Including the proposal of Oldes/Rebol-issues#2196 with caret-escape spaced, there are three main things you might want to do in a string conversion:

   * Get the "spelling" of the token without markup
   * Get the version with the markers on it
   * Get a LOADable version back

Today this isn't divided very cleanly, except that the 3rd version is ostensibly done with MOLD (which is broken, e.g. mold/all reverse http://hostilefork.com, which cannot LOAD in properly because it doesn't use construction syntax).

I propose that TO STRING! (and hence TO-STRING, the abbreviation for that) include the markings of things, while SPELLING-OF would not:

>> to-string quote set-word^_with^spaces:
== "set-word with spaces:"
>> spelling-of quote set-word^_with^_spaces:
== "set-word with spaces"
>> mold quote set-word^_with^_spaces:
== "set-word^_with^_spaces:"

With this change, there is no need for FORM...as TO-STRING takes the place and is a much clearer term. (FORM suggests some kind of user interface FORM vs. a string conversion.)

SPELLING-OF would work on ANY-STRING! types like FILE! and TAG! by giving the version without the delimiters, while TO-STRING would include them if they were appropriate.

>> spelling-of <some tag>
== "some tag"
>> to-string <some tag>
== "<some tag>"
>> spelling-of %/foo/bar
== /foo/bar
>> to-string %/foo/bar
== /foo/bar

TO-STRING of BLOCK! could work as a modified variation of FORM. It would recursively run TO-STRING on its contents, and include the outer block delimiters:

>> to-string [foo [baz bar] mumble]
== "[foo [baz bar] mumble]"

This has seemed to be the most useful behavior for the stringification of unevaluated content, which is different from COMBINE. The idea that the blocks represent something visually important that is to be preserved in the "stringification" seems to be more sensible than flattening.

This may suggest that SPELLING-OF work, but just not include the outer delimiters.

>> spelling-of [foo [baz bar] mumble]
== "foo [baz bar] mumble"

Imported from: CureCode [ Version: r3 master Type: Wish Platform: All Category: Unspecified Reproduce: Always Fixed-in:none ] Imported from: https://github.com/rebol/rebol-issues/issues/2199

Comments:


Rebolbot added the Type.wish on Jan 12, 2016