Comments on: MOLD vs TO STRING!
There is a proposal in Ticket 1404 to make mold and to string! produce different results.
>> mold #a
>> to string! #a
I like this idea, because it gives users a simple, easy-to-remember choice for removing specific datatype notations.
Let me know what you think.
Go for it. Also for other dtypes, especially money! Imagine following case:
print ["Total cost is: " cost " CZK"]
"Total cost is: $5.555 CZK"
Simply put - I there should be an easy way to remove dtype markers.
Should TO STRING! always be the same as FORM? Should there be cases where it is the same as MOLD instead? Or, should it be different from both?|
TO-STRING and FORM are only not the same in the following cases:|
BINARY!, where TO-STRING does conversion from UTF-8,
TAG!, where TO-STRING strips the brackets and FORM does not, and
BLOCK!/PAREN!, where TO-STRING strips the brackets and the separators, and FORM only strips the brackets
Single characters are converted to strings by both functions, and strings are (of course) left alone.
My opinion about TO-STRING doing conversion on BINARY! has been vented elsewhere. For the rest, I would be in favour of having TO-STRING stripping the marker(s) for the following types: PERCENT! MONEY! FILE! ISSUE!, with FORM keeping them in these cases. This makes for consistency with the other marked type: TAG!
FORM and MOLD are not the same for CHAR! STRING! FILE! TAG! and ISSUE!, and for BLOCK!/PAREN!|
If my above suggestion if followed, they will be the same for FILE! and ISSUE! as well.
In that case, the need for FORM will be greatly reduced, since either TO-STRING or MOLD can do the trick, except for BLOCK!/PAREN!.
What I would really like to see is a table that lists all datatypes on left side, and a column for each of the the FORM, MOLD, and TO STRING! outputs.
Then, we could use that table in a test file to certify the changes, because its 58 * 3 checks (although many have no effect).
There seems to be some initial work done: http://www.rebol.net/wiki/Datatype_Notes
I generated http://www.rebol.net/wiki/Datatype_string_conversion_table programmatically, and Ladislav recently made some comments on it.
My view is that we don't need multiple functions that do exactly the same thing, though I understand the redundancy with TO-* funcs. TO-STRING should be the lowest level, converting the datatype with minimal decoration; FORM should format for humans (including group separators in numbers); MOLD should format for REBOL. FORMAT should be discussed as well.
Post a Comment:
You can post a comment here. Keep it on-topic.