method-names

G++ compiler cannot distinguish variable and function with the same name? [duplicate]

一曲冷凌霜 提交于 2019-12-06 07:10:54
This question already has answers here : Closed 7 years ago . Possible Duplicate: Class method and variable with same name, compile error in C++ not in Java? The G++ compiler would complain when my class member name and member function name are the same. It seems that whenever a variable name happens to be the same as a function name, the compiler would complain. In Java, it is not the case. I just wonder why the G++ compiler cannot distinguish a variable name from a function name since the function name always comes with a pair of parenthesis. struct Callable { void operator()() const { } };

Use of special characters in function names

余生颓废 提交于 2019-12-04 08:55:56
问题 In Ruby, a standard convention is to use a question mark at the end of a method name to indicate the method returns a boolean result: [].empty? #=> true Another standard convention is to end a method name with an exclamation point if the method is destructive (that is, it modifies the original data): mylist.sort! # sort mylist in-place Recently I have seen these same conventions used in Scheme. Which makes me wonder, what other languages use/support this convention? Are there any other

Is there a technical difference between the terms “length” and “size” (in programming, of course)? [duplicate]

自闭症网瘾萝莉.ら 提交于 2019-12-03 12:32:45
问题 This question already has answers here : Closed 6 years ago . Possible Duplicate: count vs length vs size in a collection In Java in particular, on Strings , you call string.length() , whereas in Lists you call list.size() . Is there a technical difference between the two terms, seeing as a String is really just a list of chars ? Any comments appreciated. 回答1: Ideally, count would be the number of items, and size would be the amount of storage taken up (as in sizeof ). In practice, all three

Use of special characters in function names

空扰寡人 提交于 2019-12-03 01:20:51
In Ruby, a standard convention is to use a question mark at the end of a method name to indicate the method returns a boolean result: [].empty? #=> true Another standard convention is to end a method name with an exclamation point if the method is destructive (that is, it modifies the original data): mylist.sort! # sort mylist in-place Recently I have seen these same conventions used in Scheme. Which makes me wonder, what other languages use/support this convention? Are there any other special characters that are commonly used for naming by these or other languages? The answer is, of course,

How to disambiguate links to methods in scaladoc?

☆樱花仙子☆ 提交于 2019-12-03 01:11:32
I'm documenting a Scala class with overloaded methods . How can I distinguish them when referring to them in scaladoc comments? For example, if I have /** * The most important method is [[Doc.foo]]. */ object Doc { def foo[A]: A = throw new UnsupportedOperationException; def foo[A,B >: A](x: A): B = x; } and run sbt doc I get Doc.scala:1: warning: The link target "Doc.foo" is ambiguous. Several (possibly overloaded) members fit the target: method foo[A,B>:A](x:A):B in object Doc [chosen] method foo[A]:Nothing in object Doc Using foo[A,B >: A] etc. to the link doesn't work. The following seems

Is the method naming for property getters/setters standardized in IL?

こ雲淡風輕ζ 提交于 2019-11-29 09:56:41
I have the following two methods that I am wondering if they are appropriate: public bool IsGetter(MethodInfo method) { return method.IsSpecialName && method.Name.StartsWith("get_", StringComparison.Ordinal); } public bool IsSetter(MethodInfo method) { return method.IsSpecialName && method.Name.StartsWith("set_", StringComparison.Ordinal); } While this code works, I'm hoping to avoid the portion that checks the StartsWith and programmatically get the naming convention. Basically, are there any .NET 4.5 classes that are able to see if the MethodInfo is a property getter/setter? Martin Mulder A