I'm currently preparing the Racket Glossary entry for formatting and showing Racket values. My current notes are here. (The title for the entry may change; but I'm not yet sure to what. .)
I've read most of the content in these documents:
- In the Racket Guide:
- In the Racket Reference:
I have a few questions/remarks on what I read so far. I suppose none of these are essential for writing the glossary entry, but I'm curious, especially regarding the first of the following issues.
Confusion about read
and write
8.3 Reading and Writing Racket Data says on write
:
write, which prints a value in such a way that read on the output produces the value back
As a simple example, I noticed that (write 'foo)
emits foo
, not 'foo
, as I had expected. I thought the "reader" is the code that parses Racket (#lang racket
) code in files and in the REPL, but then the output should be 'foo
. If read
isn't intended for what I expected, what is its role? On the other hand, what is the corresponding infrastructure/function(s) that would translate the input string "'foo"
to the Racket data 'foo
?
"Quoting depth" and "quotable"
This paragraph has some information on the terms "quoting depth" and "quotable", but honestly that doesn't tell me anything about the actual meaning or purpose of these concepts. I thought it might have something to do with pretty-printing and experimented with the quoting depth
argument of print
in the REPL, but didn't see any differences in the output, regardless of using quoting-depth
0 or 1.
What do "quotable" and "quoting depth" actually mean? Can you show examples where different quoting-depth
arguments in print
lead to different outputs?
Parameters for read
and print
I noticed that there are many parameters for the read
and print
(starting here and here, respectively). I wonder if all these parameters are actually needed and used?
Title for the glossary entry
I'd like to have information on the following in the glossary:
print
,write
,display
functionsformat
andprintf
functions- placeholders like
~a
and~v
informat
andprintf
- functions like
~a
,~v
and~r
At the moment, I tend to put all of this in one entry, possible with subheadings as in String, character, byte string, because these concepts/functions are so closely related. Now I wonder what the title for this entry could be. Maybe just stick with "Formatting", with other terms, for example "Display", linking to the entry?
Other feedback
In addition to the notes that I linked above, is there anything you think I should include in the glossary entry? Remember that the target audience of the glossary are readers which are relatively new to Racket and may be confused by Racket's many concepts, so entries in the glossary are intended as an overview/starting point.