language-history

Why do C compilers prepend underscores to external names?

☆樱花仙子☆ 提交于 2019-12-27 11:44:37
问题 I've been working in C for so long that the fact that compilers typically add an underscore to the start of an extern is just understood... However, another SO question today got me wondering about the real reason why the underscore is added. A wikipedia article claims that a reason is: It was common practice for C compilers to prepend a leading underscore to all external scope program identifiers to avert clashes with contributions from runtime language support I think there's at least a

Why do C compilers prepend underscores to external names?

无人久伴 提交于 2019-12-27 11:44:07
问题 I've been working in C for so long that the fact that compilers typically add an underscore to the start of an extern is just understood... However, another SO question today got me wondering about the real reason why the underscore is added. A wikipedia article claims that a reason is: It was common practice for C compilers to prepend a leading underscore to all external scope program identifiers to avert clashes with contributions from runtime language support I think there's at least a

Python: Why does the int class not have rich comparison operators like `__lt__()`?

我与影子孤独终老i 提交于 2019-12-22 01:26:12
问题 Mostly curious. I've noticed (at least in py 2.6 and 2.7) that a float has all the familiar rich comparison functions: __lt__() , __gt__ , __eq__ , etc. >>> (5.0).__gt__(4.5) True but an int does not >>> (5).__gt__(4) Traceback (most recent call last): File "<input>", line 1, in <module> AttributeError: 'int' object has no attribute '__gt__' Which is odd to me, because the operator itself works fine >>> 5 > 4 True Even strings support the comparison functions >>> "hat".__gt__("ace") True but

Reasons behind naming in easy-to-confuse Python's classes such as OS and SYS?

隐身守侯 提交于 2019-12-07 13:32:44
问题 I have noticed that considerably amount of questions in SO, relating to Python, are about people messing up Sys -class, OS class and no class. For example, an easy confusing is the case: os.open("something") , open("something") and sys.open("something") . I haven't understood yet the reasons behind the naming of classes, perhaps it is just an evolution. I would like to hear why they were created with their current names? Are naming due to things like having FDs in a class? Is naming because

Reasons behind naming in easy-to-confuse Python's classes such as OS and SYS?

折月煮酒 提交于 2019-12-06 00:46:06
I have noticed that considerably amount of questions in SO, relating to Python, are about people messing up Sys -class, OS class and no class. For example, an easy confusing is the case: os.open("something") , open("something") and sys.open("something") . I haven't understood yet the reasons behind the naming of classes, perhaps it is just an evolution. I would like to hear why they were created with their current names? Are naming due to things like having FDs in a class? Is naming because some classes require special privileges? To which extent is the naming a design solution? If you cannot

What is the point of the complicated scoping rules for friend declarations?

随声附和 提交于 2019-12-05 16:30:18
问题 I recently discovered that friend declarations scoping follows extremely peculiar rules - if you have a friend declaration (definition) for a function or a class that is not already declared, it is automatically declared (defined) in the immediately enclosing namespace, but it is invisible to non-qualified and qualified lookup; however, friend function declarations remain visible through argument-dependent lookup. struct M { friend void foo(); friend void bar(M); }; void baz() { foo(); //

What is the meaning of “Hero unit”?

时光总嘲笑我的痴心妄想 提交于 2019-12-05 09:20:58
问题 What does the term "hero" mean and why was it used to name a site/page's "primary message"? Specifically I'm wondering if the term "hero" or phrase "hero unit" is some common nomenclature used in web design that I've managed to miss. 回答1: The term "hero" is used by movie/television prop designers; a "hero prop" is the one built for closeups. It's got the most detail, and is most realistic. It's the best version of a prop, the most important one. I have always assumed that where they got the

Python: Why does the int class not have rich comparison operators like `__lt__()`?

放肆的年华 提交于 2019-12-04 22:29:38
Mostly curious. I've noticed (at least in py 2.6 and 2.7) that a float has all the familiar rich comparison functions: __lt__() , __gt__ , __eq__ , etc. >>> (5.0).__gt__(4.5) True but an int does not >>> (5).__gt__(4) Traceback (most recent call last): File "<input>", line 1, in <module> AttributeError: 'int' object has no attribute '__gt__' Which is odd to me, because the operator itself works fine >>> 5 > 4 True Even strings support the comparison functions >>> "hat".__gt__("ace") True but all the int has is __cmp__() Seems strange to me, and so I was wondering why this came to be. Just

Historic reasons for Left-Handed Coordinate System

∥☆過路亽.° 提交于 2019-12-04 03:14:12
问题 I find it a bit non-intuitive that the (0,0) maps to the left-top of the screen. Is there a historic reason for using a left-handed coordinate system in Java Swing? While mapping this to a right-handed system is not too difficult, I'm curious to know if there is any hidden benefit in having a left-handed system. 回答1: According to this article that's simply because that's the way it always was with television sets (which hasn't changed, BTW). So it seems that this early design decision still

Historic reasons for Left-Handed Coordinate System

纵饮孤独 提交于 2019-12-01 16:34:46
I find it a bit non-intuitive that the (0,0) maps to the left-top of the screen. Is there a historic reason for using a left-handed coordinate system in Java Swing? While mapping this to a right-handed system is not too difficult, I'm curious to know if there is any hidden benefit in having a left-handed system. According to this article that's simply because that's the way it always was with television sets (which hasn't changed, BTW). So it seems that this early design decision still has an impact today. Early home computers often were connected to the TV, so naturally they used this