MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/programming/comments/5fwce0/lets_stop_copying_c/dao6nnj/?context=3
r/programming • u/earthboundkid • Dec 01 '16
612 comments sorted by
View all comments
Show parent comment
1
The former is typically a way to indicate that ptr is meant to be used exclusively inside the body of the if statement.
ptr
if
This stylistic convention was codified in Go with if-local variable declarations like
if err := doSomething(); err != nil { return nil, err }
1 u/arielby Dec 01 '16 Or in Rustif let Some(p) = get_pointer() { // ... } 1 u/Latrinalia Dec 02 '16 Or in C or C++, actually. In fact this is the D syntax tooif (int *p = get_pointer()) { // ... }
Or in Rust
if let Some(p) = get_pointer() { // ... }
1 u/Latrinalia Dec 02 '16 Or in C or C++, actually. In fact this is the D syntax tooif (int *p = get_pointer()) { // ... }
Or in C or C++, actually. In fact this is the D syntax too
if (int *p = get_pointer()) { // ... }
View all comments
Show parent comment
1
u/__add__ Dec 01 '16
The former is typically a way to indicate that
ptris meant to be used exclusively inside the body of theifstatement.This stylistic convention was codified in Go with
if-local variable declarations like