I've seen a few function definitions like this recently while playing with GNU Bison:
static VALUE
ripper_pos(self)
VALUE self;
{
//code here
}
Why is the type of self
outside of the parenthesis? Is this valid C?
Those are old K&R style function parameter declarations, declaring the types of the parameters separately:
int func(a, b, c)
int a;
int b;
int c;
{
return a + b + c;
}
This is the same as the more modern way to declare function parameters:
int func(int a, int b, int c)
{
return a + b + c;
}
The "new style" declarations are basically universally preferred.
This is the so-called "old" variant of declaring function arguments. In ye olden days, you couldn't just write argument types inside the parentheses, but you had to define it for each argument right after the closing parenthesis.
In other words, it is equivalent to ripper_pos( VALUE self )
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With