REBOL 3.0

Comments on: MOLD vs TO STRING!

Carl Sassenrath, CTO
REBOL Technologies
5-Feb-2010 6:18 GMT

Article #0304
Main page || Index || Prior Article [0303] || Next Article [0305] || 8 Comments || Send feedback

There is a proposal in Ticket 1404 to make mold and to string! produce different results.

Example:

>> mold #a                 
== "#a"
>> to string! #a           
== "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.

8 Comments

Comments:

Oldes
5-Feb-2010 3:06:47
I agree
-pekr-
5-Feb-2010 3:37:04
Go for it. Also for other dtypes, especially money! Imagine following case:

cost: $5.555 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.

Gabriele
5-Feb-2010 5:26:49
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?
meijeru
6-Feb-2010 6:29:58
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!

meijeru
6-Feb-2010 8:46:24
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!.
Carl Sassenrath
7-Feb-2010 13:49:51
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).

-pekr-
7-Feb-2010 16:26:08
There seems to be some initial work done: http://www.rebol.net/wiki/Datatype_Notes

Gregg Irwin
17-Feb-2010 13:43:09
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.

Name:

Blog id:

R3-0304


Comment:


 Note: HTML tags allowed for: b i u li ol ul font span div a p br pre tt blockquote
 
 

This is a technical blog related to the above topic. We reserve the right to remove comments that are off-topic, irrelevant links, advertisements, spams, personal attacks, politics, religion, etc.

REBOL 3.0
Updated 30-Apr-2017 - Edit - Copyright REBOL Technologies - REBOL.net