On 10/21/24 12:26 PM, Alice Ryhl wrote:
On Mon, Oct 21, 2024 at 9:09 PM John Hubbard <jhubbard@xxxxxxxxxx> wrote:
On 10/21/24 11:59 AM, Alice Ryhl wrote:
On 10/21/24 8:41 PM, John Hubbard wrote:
On 10/21/24 11:37 AM, Miguel Ojeda wrote:
On Mon, Oct 21, 2024 at 8:35 PM John Hubbard <jhubbard@xxxxxxxxxx> wrote:
Is this another case of C and Rust using different words for things??
Wow. OK...
I am not sure what you mean -- by BE I meant British English.
See my other reply as well -- I just changed it anyway because Rust
apparently uses "parentheses".
Right. For spoken languages, that's simply preference, and I would not
try to impose anything on anyone there.
But in this case, at least for C (and, from reading my Rust book(s), I
thought for Rust also), "parentheses" is a technical specification, and
we should prefer to be accurate:
parentheses: ()
brackets: []
Yes?
What word would you use to collectively talk about (), [], {}? In my native language they're all a kind of parenthesis.
Good question. I've never attempted that when discussing programming
language details, because it hasn't come up, because it would be a
programming error in C to use one in place of the other. And it is
rare to refer to both cases in C.
Rust so far seems to have the same distinction, although I am standing
by to be corrected as necessary, there! :)
At a higher level of abstraction, though, perhaps "grouping" is a good
word.
Rust macros can use different types of brackets. For example, the
`assert!(1 < 2)` macro uses round parenthesises, the `vec![1,2,3]`
macro uses square parenthesises, and the `thread_local! { ... }` macro
uses curly parenthesies. The round and square brackets are used for
expression-like things, and the curlies are used for things that
expand to top-level items such as global variables or functions.
Macros cannot use any other delimiter than those three. So e.g. <>
wouldn't work.
That answers my implicit "are there any cases in which you would
want to collectively refer to all three types of...bracket?", yes.
For the original point, though, we are not in a Rust macro. Is it
actually allowable to use [] or {} here:
+ // Brackets around PAGE_SIZE-1 to avoid triggering overflow sanitizers in the wrong cases.
+ (addr + (PAGE_SIZE - 1)) & PAGE_MASK
? Is that why you were not seeing a difference between saying "brackets"
vs. "parentheses" there? If so, this would be yet another case of my
Rust newbie-ness being inflicted on you. :)
thanks,
--
John Hubbard