271 reputation
15
bio website
location
age
visits member for 2 years, 10 months
seen Feb 27 at 10:32

Feb
27
comment What argument passing mechanism does python use, and where is this officially documented?
That's exactly what's called pass-by-value -- passing works the same way as assigning.
Feb
5
comment Overriding equals() method in Java
@InstructedA: Adding lots of special cases for particular methods to the language is bad design.
Feb
5
comment Overriding equals() method in Java
@InstructedA: Those interfaces don't specify any methods. (They are called "marker interfaces".) There is nothing special about that. Anyone can make any number of interfaces that don't have any methods.
Feb
5
comment Overriding equals() method in Java
@InstructedA: There is nothing special compiler-wise about Cloneable and Serializable, except that arrays automatically implement both.
Feb
4
comment Overriding equals() method in Java
@InstructedA: There is no syntax or construct in Java (or any other language AFAIK) to make a method "overrideable once, but the override cannot be overridden" without the override choosing it as such.
Feb
4
comment Overriding equals() method in Java
If Object.equals() were not overrideable, then it would be the same as ==, and so would be redundant and unnecessary.
Jan
30
comment Java - Get Interface Generic Type
@Doval: Those are different. A class file can be thought of as consisting of declarations (kind of like "headers") and code. Generics in the compile-time declarations -- the declarations of classes, fields, methods, superclasses, superinterfaces, etc. are hard-coded in the class file and can be retrieved via reflection at runtime. But in actual compiled "code" and for values at runtime, there is no generics.
Jan
17
awarded  Critic
Dec
13
comment Why use arg type `class Object` instead of `Comparable[]`?
"By the way, let's forget about generics for a moment: after all, early versions of Java, for which sort was implemented, did not provide generics." But the question doesn't have anything to do with generics -- both Object[] and Comparable[] are non-generic. So the "early versions of Java" could use Comparable[].
Dec
13
comment Why use arg type `class Object` instead of `Comparable[]`?
"Both checks can be done at runtime" If by "checked at runtime" you mean, try it and see if it throws an exception, then yes. Otherwise, #2 is not guaranteed to be checkable at runtime.
Dec
13
comment Why use arg type `class Object` instead of `Comparable[]`?
"one can be safe from runtime exceptions because every passed object has to implement interface Comparable" That would still not be safe from runtime exceptions. In order to sort, you need to make sure that the type is comparable to itself. You need a bound like <T extends Comparable<? super >>. Otherwise, it is still not safe. You will still get a warning.
Dec
10
comment Why is the hashCode method usage of HashSet not specified in the API?
@RossPatterson: Right, because sets and maps are analogous and can be implemented in terms of one another.
Dec
9
comment Why is the hashCode method usage of HashSet not specified in the API?
@RossPatterson: Well, it has to use .hashCode(), because the point of using HashSet is that it has average-case constant complexity for lookup, insertion, and deletion. And that is only possible if it uses .hashCode() for a hash table.
Dec
9
revised Why is the hashCode method usage of HashSet not specified in the API?
added 74 characters in body
Dec
9
answered Why is the hashCode method usage of HashSet not specified in the API?
Dec
5
answered Where is it specified that Java is call by value?
Dec
3
comment Performance of Class methods vs singleton instance methods
A class is an object and there is no difference in the process of sending a message to an object between if the receiver is a class or not. Every method is an "instance method" of some instance. Every method call goes through objc_msgSend (or related functions), and does not call any of the functions you listed above. However, there is a difference before the call in that a singleton object needs to be gotten somehow whereas a class object is known and hard-coded at compile-time.
Dec
2
comment Performance of Class methods vs singleton instance methods
@amon: However, to call instance methods on the singleton, he would presumably have to call something to "get" the singleton object, which is another call; whereas for calling a class method, the class object is provided directly.
Dec
1
comment What argument passing mechanism does python use, and where is this officially documented?
@delnan: In any language, "value" is an overly broad term. In C, when the parameter is a pointer type, is the "value" the address, or the thing pointed to? Same in Java. But "pass-by-value" and "pass-by-reference" should not depend on vague notions of terms like "value" -- Here is a definition only on semantics: when you assign to a parameter inside the function, and it has the same effect as assigning to the passed variable in the calling scope, that is pass-by-reference; when it has no effect on the calling scope, that is pass-by-value. This is consistent with how it is used in C++ and Java.
Dec
1
comment What argument passing mechanism does python use, and where is this officially documented?
@delnan: The only definition of pass-by-value/pass-by-reference that I have seen that is consistent across languages, and only relies on semantics and not vague terms, is the one where C/Java/Python/Ruby are pass-by-value only. No other definition I've seen commonly is used in a semantically consistent way.