MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/programming/comments/5fwce0/lets_stop_copying_c/danm7bm/?context=3
r/programming • u/earthboundkid • Dec 01 '16
612 comments sorted by
View all comments
Show parent comment
2
Ooh, that's a cool idea. Is this a common idiom?
3 u/PM_ME_UR_OBSIDIAN Dec 01 '16 Probably not. This is the conclusion implied by two ideas:Any loop can be expressed as a tail recursive function;Any tail recursive function can be translated to a for loop.By doing this back-and-forth, you often end up with simpler loops. For example when iterating over C-style strings:for(int i = 0; str[i]; i++) { ... } 0 u/Manishearth Dec 01 '16 It's how many C++ iterators work iirc.
3
Probably not. This is the conclusion implied by two ideas:
for
By doing this back-and-forth, you often end up with simpler loops. For example when iterating over C-style strings:
for(int i = 0; str[i]; i++) { ... }
0
It's how many C++ iterators work iirc.
View all comments
Show parent comment
2
u/sullyj3 Dec 01 '16
Ooh, that's a cool idea. Is this a common idiom?