7 ms·
I know :) ... but have you seen anyone actually use those? I'd be curious to get a pointer or two.
by eqvinox 7y ago
I know :) ... but have you seen anyone actually use those? I'd be curious to get a pointer or two.
- dllu 7y agoI have seen people coming to C++ from Python use "and", "or", and "not" in their if-statements :)
- eqvinox 7y agoHah - I kid you not, I have the reverse problem! I work a lot with both C and Python (embedded interpreter & CPython extensions) and whenever I switch from a stretch of C coding to doing some Python, I catch myself typing "&&" and "||" instead of "and" and "or" :D (C is my "native" language, so it doesn't really happen the other way around, but that's just me) But honestly, I'm pretty sure we can call iso646.h "fringe" ;)
- aloisdg 7y agoIn programming languages, does we have something akin to a mother-tongue?
- macintux 7y agoThere’s a fair bit of debate about the impact of learning specific programming styles as your first language. Quite a few people would argue that learning functional programming first is a benefit to understanding the concept of state and how to write clean code, even if you end up using something less pure. Certainly, speaking as someone brought up on imperative and later OO code, it took a fair bit of unlearning to understand functional programming, and I still have no clue about type theory.
- int_19h 7y agoCuriously, & and | are occasionally useful in Python. They do work properly with booleans, so the difference compared to "and" and "or" is that you don't get short circuiting, which in some very rare cases you might not want. ^ is less useful because it's almost the same as != (except stricter about types) - but it documents the intent more clearly.
- jcelerier 7y agowhat's the problem ? it's legal C++ (https://en.cppreference.com/w/cpp/language/operator_alternative https://en.cppreference.com/w/cpp/language/operator_alternat...) and imho more readable than && / ||
- eqvinox 7y agoWe're talking about C here, not C++. The keywords don't exist in C unless you #include "iso646.h"
- jcelerier 7y agolet me quote you the comment I was replying to : > I have seen people coming to C++ from Python use "and", "or", and "not" in their if-statements :)
- eqvinox 7y agoYet curiously absent from that quoted comment is anything about it being a problem, which you nonetheless ask about. I wonder if more context or a more well-intentioned reading is the solution? ;)
- jcelerier 7y agoI read and reread it and I honestly don't understand how it is possible to come up with an interpretation where that is not seen as an issue by the author
- pjmlp 7y agoSo what? Unless you include std...h you also need to use _Bool, _Complex and so forth, hardly much different.
- int_19h 7y agoBut the repo doesn't include them - it defines them itself. Technically, I believe this is actually UB, just like any other #define for a keyword or an identifier from the standard library.
- saagarjha 7y agoTwice: once for a CTF challenge that stripped out certain symbols, and one other time when I set up an emulator with a sketchy key map and didn’t want to bother figuring out what those symbols were mapped to.
- ritter2a 7y agoI've only seen wrong use: CS students working on a project in C++, using "and" and "or" as identifiers (which their local MSVC compiler apparently was cool with) and then being surprised that the course's testing environment (using gcc) found some errors.