5 ms·
> His terminology is all over the map and typically inaccurate, if not plainly wrong. > Expressions “return a value.” > “A pointer is a special variable that
by Droobfest 6y ago
> His terminology is all over the map and typically inaccurate, if not plainly wrong.
> Expressions “return a value.”
> “A pointer is a special variable that returns the address of a memory location.”
I don't see how these are clearly wrong? I guess the 'returning' is problematic?
Somehow I feel this was written with an air of superiority, the author doesn't expand on anything. I get that feeling a lot with articles about c.
- masklinn 6y agoThe first one is a bit odd, and in C expressions specifically don’t always return values: void functions. The second one reads really strange to me, and variables don’t return things.
- TomSwirly 6y agoI've been writing C since the 1980s. Sorry, this book is not just bad but astonishingly bad. Your examples are just wrong. "Returning" has a very specific meaning in programming. An expression does not "return a value". A pointer very very much does not "return the address of a memory location". The code example given was utterly awful. If you cannot see why that code example is almost guaranteed to cause problems, you might not want to continue in this discussion...
- kaetemi 6y agoWhat's the verb in this case then? "An expression ___ a value."
- croes 6y agoIt would be a great help if you use the correct terms instead of just pointing out the wrong ones.
- Droobfest 6y ago> If you cannot see why that code example is almost guaranteed to cause problems, you might not want to continue in this discussion... Why not? Wouldn't it be especially important to educate these people? Overly ignorant people sure can be annoying, but at least give people some information on the right concepts instead of only derision.
- captainmuon 6y agoSure its sloppy, but in my experience at least it's a very widespread and normal terminology. Colloquially, an expression is something on the right hand side of `=` or in parentheses, and that returns a value. Most importantly, "returns" implies that some kind of computation may go on, maybe with side effects. I'm aware that the C standard uses the terms differently, but there is usually a difference between the mental model and the C standard, or the parser.
- rootlocus 6y agoAn expression evaluates to a value. That value may be an lvalue, and it can be present on the left hand side of `=`.
- molf 6y ago> Expressions “return a value.” Yes, "returning" is problematic, because that has a very specific meaning in the context of a function call. But even if we forgive the author the inaccurate terminology, it is also an incorrect statement. You can evaluate an expression. But in C in particular, an expression does not necessarily evaluate to a value. A somewhat better statement might be: "Expressions can be evaluated. Some expressions produce a result value." This statement can probably further improved upon; it definitely still does not capture everything that expressions are in C: such as being able to cause side-effects! That might not be evident, but can certainly be important. But then again, I am not writing a book about C. > “A pointer is a special variable that returns the address of a memory location.” Indeed "returning" is problematic here. A pointer does not return anything, it points to something. > Somehow I feel this was written with an air of superiority, the author doesn't expand on anything. I get that feeling a lot with articles about c If you're going to write a book about C in order to teach programmers how to work with pointers, better explain things with the correct terminology. If this were a journal, then of course you can forgive the inaccuracies. But it's a published book that supposedly teaches certain concepts to readers. The author of the blog post says as much in their notes: "This provides some insight into the mind of the author: he's just picking up concepts and terms as he learns about them and tossing them in without any regard for the reader. This book is pretty much his journal — that somehow became a book with two editions." > the author doesn't expand on anything The author expands on a lot more than I would have the patience for; see the notes [0]. Why certain things are incorrect, misleading or dangerous does require some C knowledge. The article + notes won't be a place to learn more about C; but neither is the book that's being reviewed. [0]: https://wozniak.ca/blog/2018/06/25/1/notes.html https://wozniak.ca/blog/2018/06/25/1/notes.html
- kaetemi 6y agoAlthough, if you are writing a book to teach programming, you can't suddenly drop stuff like "evaluating expressions" on readers either. It might be meaningless to them. For example. If they come from a 'toy' programming background where they just call functions that return values, set variables, jump to labels, and do some math... Even if they're experts at that task, the words "evaluating expressions" might likely have no meaning to them at all. You'll have to explain first with concepts they already understand. In this case, it seems the writer might've come from such a background. (And assumed his contemporaries were in a similar mindset.) :)