For example:
struct lg_buf *lg_buf_init(struct lg_buf *_) {
_->data = NULL;
_->len = _->cap = 0;
return _;
}For example:
struct lg_buf *lg_buf_init(struct lg_buf *_) {
_->data = NULL;
_->len = _->cap = 0;
return _;
}One such instance is the abbreviated scala lambda syntax, where (x:Int) => x + 2 can be abbreviated to _ + 2 in the same way that kotlin would allow abbreviating it as { it + 2 } with its equivalent default lambda parameter name, "it".
In the example you quoted, the identifier denotes the sole parameter, so in a sense its name does not matter, and as such people from certain programming circles might be inclined to use an underscore instead of taking the time to come up with an appropriate name. It's not like a more descriptive name would help in that example, the type name and function name already give sufficient context for it to be perfectly clear what the parameter is for, and it's not like parameter names have any semantic significance in C.
I agree, and I’ve been thinking about this today. There is also a minimalistic quality to this style, the _ pointer is more prominent simply by not having a real name. I like it!
http://www.tutorialspoint.com/perl/perl_special_variables.ht...
(The $ sigil denotes that the variable is a scalar; all Perl variables have a sigil like that.)
So this reads naturally to me: _ is the lg_buf, it doesn't need a real name like "buf", because it's just "the thing" or "it".
The ISO C standard in section 7.1.3 states that global functions and variables in compiler/system libraries should be prefixed with an underscore to avoid the risk of conflict with names in user programs.
I checked and indeed... lg_buf is a global variable.
But I've never seen anyone use just the underscore prefix without a name before.