1,955 reputation
715
bio website kdgregory.com
location
age
visits member for 4 years, 1 month
seen 2 days ago

Dec
30
comment What is different between the internal design of Java and C++ that lets C++ have multiple inheritance?
... which is why Java has distinct invokevirtual and invokeinterface operations (as well as several other forms of method invocation).
Dec
30
comment What is different between the internal design of Java and C++ that lets C++ have multiple inheritance?
@DVK - it's extremely difficult to give you an appropriate answer to this question. The trivial answer is that, because Java uses dynamic dispatch, there is nothing physically standing in the way of supporting multiple inheritance. However, it's unclear whether you understand how dynamic dispatch works (even though you mention v-tables), so a real answer would need to expand on how the compiler translates a method call into an indirect lookup. Or, at the other end, there are performance implications depending on the ordering of methods ...
Dec
30
comment What is different between the internal design of Java and C++ that lets C++ have multiple inheritance?
One could even say that Java is vtables all the way down.
Dec
26
comment Algorithm to merge two sorted arrays with minimum number of comparisons
You could create some adaptive algorithm that attempts to use a merge size > 1, but that isn't going to get you significant savings. A better solution is to map the source arrays into a form that is inexpensive to sort. This, however, depends on your actual situation (and neither of your examples would justify it).
Dec
24
comment What'd be better? To add one more local variable, or to call a method twice in general case?
@Doval - Yes IO is a side-effect. In my original edit I only had two points, but then thought that someone would be sure to call me out on volatile reads. That said, I think that it's important to understand and recognize the difference between what I'll call "active" and "passive" side-effects: the former are caused by your action, the latter are caused by external action. In my experience, most concurrency bugs are a result of the latter, not the former.
Dec
24
comment What'd be better? To add one more local variable, or to call a method twice in general case?
@BartvanIngenSchenau - I always find that profiling leads to more dramatic code restructuring than simply introducing a variable.
Dec
24
answered What'd be better? To add one more local variable, or to call a method twice in general case?
Dec
23
comment Disadvantages of Pointers
For whatever reason, the chat page thinks that I'm not logged in. So to respond to your earlier comment, I've updated the tag wiki to give a better explanation of what a "pointer" is.
Dec
22
revised pointers wiki description
added 6 characters in body
Dec
22
suggested approved edit on pointers tag wiki
Dec
22
awarded  Tag Editor
Dec
22
revised pointers wiki description
greatly expanded, with examples
Dec
22
suggested approved edit on pointers tag wiki
Dec
22
awarded  Nice Answer
Dec
18
comment Why can't the Scala compiler give pattern matching warning for nonsealed classes/traits?
It's unclear what you're asking. Do you want the compiler to emit a warning if the match expression doesn't cover all possible inputs? Perhaps an example would make your question more clear.
Dec
18
revised Calculating physical address given only an offset for my process
add diagram
Dec
18
awarded  Editor
Dec
18
revised Calculating physical address given only an offset for my process
add diagram
Dec
18
answered Calculating physical address given only an offset for my process
Dec
9
comment Using reflection vs creating a new class
Are you able to reflect on the Egg to determine what components it contains?