Conversation

Björkus "No time_t to Die" Dorkus

"function body" which, by grammar definition, refers to just the compound statements, but in the prose definition in the C Standard also includes the parameters and shit.

God.

2
0
1

I'll probably transition to using the language "function statement body" or "function core body" or something for the actual statement bits.

Suggestions welcome, tbh, since "function body" is not something that will change for a while so it can't be "body".

Ugh. This standard sucks.

2
0
1

@thephd “function body block”? as in “the block in the function body”, as in “a block { (stmt;)* }“. not sure how well this fits C, but I’m used to e.g. Rust having a “block expression” with that brace syntax.

this could also be uniform with something like an “if then body block”, an “if else body block”, a “for loop body block”, and a “while loop body block”. emphasis in these names on “then body”, “else body”, “loop body”, while also explicitly specifying just as in the function body block, that it strictly refers to the block part of the syntax.

0
0
0

@thephd i love inconsistenciesl ike that in specs

i think my favorite one of them got to be ecma 404’s grammar definition of a number including fractional, negative, and numbers with exponent, but its prose definition disagreeing with itself about whether they are valid

1
0
4
Edited 9 months ago

@thephd (basically down to the decimal point, the minus symbol, and the letter e not being digits. -3.14e0 is valid by grammar but it can’t be represented by a sequence of digits bc it’s not a natural number)

1
0
1

@thephd also c number types are a heaven compared to whatever the fuck json has with no specified range or precision

0
0
2

Björkus "No time_t to Die" Dorkus

@JamesWidman From the standard, N3685, §6.8.5, ❡2:

A compound statement that is a together with the parameter type list and the optional attribute specifier sequence between them forms the block associated with the function definition in which it appears.

So the block traditionally created by "everything between the opening and closing brace of the function body" is for the whole function body. If you need a block for JUST the function body, it doesn't exist.

0
0
0

I should have mentioned that "block" is not good for the reasons I wrote here:

https://pony.social/@thephd/115375502032070623

That is, the standard says that the body of a function has a block scope that includes the parameters too. So, I need to define a new scope that's inside that scope.

1
0
0

@thephd why do you need to define a new scope? wouldn't that allow parameters and stuff to be shadowed?

1
0
0

@sebastian "define a new scope" is something I'm using loosely, here: I just need something that refers to the literal function body and not its parameters for the purposes of constraints.

0
0
0

Björkus "No time_t to Die" Dorkus

@JamesWidman that's not a defect, it's saying the opposite.of what you're thinking. It's a block, or the block PLUS the function arguments when it's a function definition (ie a function-body).

0
0
0