REBOL3 tracker
  0.9.12 beta
Ticket #0002199 User: anonymous

Project:

Previous Next
rss
TypeWish Statussubmitted Date4-Mar-2015 19:52
Versionr3 master CategoryUnspecified Submitted byfork
PlatformAll Severityminor Prioritynormal

Summary Change behavior of TO-STRING to replace FORM, add SPELLING functions
Description Including the proposal of #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"
Example code

			

Assigned ton/a Fixed in- Last Update4-Mar-2015 20:06


Comments

Date User Field Action Change
4-Mar-2015 20:06 Fork Description Modified -
4-Mar-2015 20:05 Fork Summary Modified Change behavior of TO STRING! to replace FORM, add SPELLING functions => Change behavior of TO-STRING to replace FORM, add SPELLING functions
4-Mar-2015 20:05 Fork Summary Modified Change behavior of TO-STRING to replace FORM, add SPELLING functions => Change behavior of TO STRING! to replace FORM, add SPELLING functions
4-Mar-2015 20:05 Fork Description Modified -
4-Mar-2015 19:54 Fork Description Modified -
4-Mar-2015 19:54 Fork Description Modified -
4-Mar-2015 19:52 Fork Ticket Added -