4 ms·
The example says no mysticism but is using at least 4 undeclared variables. I’m not a C developer so I’m sure I’m completely wrong, but where do pledge, puts, E
by sbr464 8y ago
The example says no mysticism but is using at least 4 undeclared variables. I’m not a C developer so I’m sure I’m completely wrong, but where do pledge, puts, EXIT SUCCESS/FAILURE come from?
I assume from importing stdlib etc, which probably give you additional variables to use, that you would need to know about explicitly. One thing I like about zeit.co’s micro server (js) was the argument about not using bodyparser and magically having res.body available, but using async/await and assigning it to a variable. This is popping up more with things like es module imports, render props in react, etc. They make it clear where variables come from and allow you to avoid stepping on existing variables. What other 10-100 variables can I step on potentially with global patterns as a new user?
- beefhash 8y ago> I’m not a C developer so I’m sure I’m completely wrong, but where do pledge, puts, EXIT SUCCESS/FAILURE come from? - pledge: unistd.h[1] - puts: stdio.h[2] - EXIT_SUCCESS and EXIT_FAILURE: stdlib.h[3] You can probably safely assume a C programmer is familiar with puts and EXIT_SUCCESS/EXIT_FAILURE and that an OpenBSD programmer has heard of pledge(2). [1] https://man.openbsd.org/pledge.2 https://man.openbsd.org/pledge.2 [2] ISO C11, § 7.21.7.9 no. 1; https://man.openbsd.org/puts.3 https://man.openbsd.org/puts.3 [3] ISO C11, § 7.22 no. 3
- sbr464 8y agoThanks for that info. I do need to learn C still.
- cpmouter 8y agoIt's surprising to me that someone could be a programmer without knowing anything about C.
- scandox 8y agoThe best programmer in the world may never have even seen a computer for all we know.
- carapace 8y agoDijkstra famously didn't use one until his friends and colleagues made him get a mac so they could email him.
- Senderman 8y agoI was programming for a few years before I first encountered C, and that was almost 2 decades ago. I don't think it's that uncommon.