Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Q&A

Post History

60%
+1 −0
Q&A Syntax summaries use brackets for optional elements; how do I represent literal brackets in a way readers will understand?

Assuming you're not limited to US-ASCII in notation, I think the best approach would be to find bracket characters or some other notation that won't conflict with any characters that will need to b...

posted 4y ago by Peter Cooper Jr.‭

Answer
#1: Initial revision by user avatar Peter Cooper Jr.‭ · 2020-11-04T14:28:05Z (about 4 years ago)
Assuming you're not limited to US-ASCII in notation, I think the best approach would be to find bracket characters or some other notation that won't conflict with any characters that will need to be literally in the command. There are a lot of [bracket characters in Unicode](https://en.wikipedia.org/wiki/Bracket#Encoding), so something like this could work:

    ARRAY[data-type ⌞, count⌟]

Though that of course requires defining your notation in a clear way in each place someone might stumble upon it.

The other option is to just be overly verbose in each example, calling out the optional parts:

    ARRAY[data-type, count]
                   └──┬──┘
                     The count is optional, but if included must be preceded by a comma.
                     If the count is not included, the comma must also be omitted.

But that's probably a bit much. As you say, not calling out parts as "optional" explicitly and just showing all the possible cases may be the clearest approach for what you're trying to do.