If you need help, try to find the answer through the following path: `Help` in the console ⇒ [Red by Example](https://www.red-by-example.org/) ⇒ [Official Red Docs](https://github.com/red/docs/blob/master/en/SUMMARY.adoc) ⇒ [Rebol Core Manual](http://www.rebol.com/docs/core23/rebolcore.html ⇒ [Red Wiki](https://github.com/red/red/wiki ⇒ Net search "redlang + your-question" ⇒ Ask us, we are here to help!
form
to present #{616D73} as 616D73, like rebol.form
doing any extra work, the Red result is technically correct, right?format
, print
, etc
R2:
>> form #{616D73}
== "#{616D73}"
R3:
>> form #{616D73}
== "#{616D73}"
Formed values are determined on a type by type basis, as to what is best. We could make hard and fast rules, but that would produce more technically consistent, but perhaps less useful results. When form
says "user-friendly string representation" it's a softer, more flexible rule than mold
.
Here's the question I asked:
I'd like to see why people want this form. What are the use cases?
Start there.
>> mold #{3132}
== "#{3132}"
>> form #{3132}
== "3132"
>> to string! #{3132}
== "12"
enbase/base
occurs in a lot of old R2 code, not always base 16. Without digging in, the use case that jumps out at me is emitting data, because other formats, like XML or JSON, may want values as hex strings, and the return value of checksum
is a key partner there. But that's not really where form
is best applied, since it's for data interchange.
here I would now use:
md5: form checksum skip inBuffer 2 'md5
instead of:
md5: enbase/base checksum/method skip inBuffer 2 'md5 16
@Oldes, I think we're seeing the same patterns.
@ne1uno where are hex colors used as binary!
in Red? e.g. pixels in images are tuples.
My suggestion is to look at to-hex
and see if it can be extended (I wish it were a mezz, for easier playing). It's used in the Red codebase is in the JSON emitter, for \u
chars, but a dozen places or so in %.r support files in the core. It returns an issue, as R2 did, but bear in mind that they were a string type in R2 and a word type in Red. @ne1uno already noted that it's an alternative approach to enbase
.
Format
will likely have hex output support, as a side note.
For now, I'd wrap enbase
, though we have a number of places "hex" is used in a name, but for different purposes. form-as-hex
could be a name to use as a playground.
#{
and }
.
-c
may fail for numerous reasons, depends on your code
on-change []
could append chars and reset face/text: "**"