internals

How are java interfaces implemented internally? (vtables?)

天大地大妈咪最大 提交于 2019-12-17 15:27:44
问题 C++ has multiple inheritance. The implementation of multiple inheritance at the assembly level can be quite complicated, but there are good descriptions online on how this is normally done (vtables, pointer fixups, thunks, etc). Java doesn't have multiple implementation inheritance, but it does have multiple interface inheritance, so I don't think a straight forward implementation with a single vtable per class can implement that. How does java implement interfaces internally? I realize that

Order of static constructors/initializers in C#

我怕爱的太早我们不能终老 提交于 2019-12-17 12:14:10
问题 While working on a C# app I just noticed that in several places static initializers have dependencies on each other like this: static private List<int> a = new List<int>() { 0 }; static private List<int> b = new List<int>() { a[0] }; Without doing anything special that worked. Is that just luck? Does C# have rules to resolve this? Edit: (re: Panos) In a file lexical order seems to be king? what about across files? In looking I tried a cyclical dependency like this: static private List<int> a

Python string interning

社会主义新天地 提交于 2019-12-16 19:30:13
问题 While this question doesn't have any real use in practice, I am curious as to how Python does string interning. I have noticed the following. >> "string" is "string" >> True This is as I expected. You can also do this. >> "strin"+"g" is "string" >> True And that's pretty clever! But you can't do this. >> s1 = "strin" >> s2 = "string" >> s1+"g" is s2 >> False Why wouldn't Python evaluate s1+"g" , and realize it is the same as s1 and point it to the same address? What is actually going on in

Does erlang implement record copy-and-modify in any clever way?

。_饼干妹妹 提交于 2019-12-13 11:37:42
问题 given: -record(foo, {a, b, c}). I do something like this: Thing = #foo{a={1,2}, b={3,4}, c={5,6}}, Thing1 = Thing#foo{a={7,8}}. From a semantic view, Thing and Thing1 are unique entities. However, from a language implementation standpoint, making a full copy of Thing to generate Thing1 would be intensely wasteful. For example, if the record were a megabyte in size and I made a thousand "copies," each modifying a couple of bytes, I've just burned a gigabyte. If the internal structure kept

How does pycharm work? How did they hook into the interpreter?

痞子三分冷 提交于 2019-12-12 10:11:28
问题 I know how to use PyCharm's debugger but that has only deepened my curiosity of how it accomplishes the task of being so tightly coupled to the Python interpreter. Does cPython have some sort of intrepreter hooks buried in itself or does PyCharm somehow copy the source code, instrument the code, and then exec it? 回答1: Thanks to @unholySheep I was able to go from the github src on PyDev.Debugger back to sys.settrace which lead to a post on Python Module of the week on settrace. Once the

PeakVirtualMemorySize64, PeakWorkingSet64 and PeakPagedMemorySize64 for a process have different value if we executed several time?

我怕爱的太早我们不能终老 提交于 2019-12-12 03:38:54
问题 I run a code multiple time and i measure in the end of it the PeakPagedMemorySize64 , PeakWorkingSet64 and PeakVirtualMemorySize64 using the Process class . But in each time i get different value for the same code PeakPagedMemorySize64 112758784 PeakVirtualMemorySize64 332701696 PeakWorkingSet64 143835136 PeakPagedMemorySize64 113696768 PeakVirtualMemorySize64 332636160 PeakWorkingSet64 144642048 PeakPagedMemorySize64 113528832 PeakVirtualMemorySize64 332701696 PeakWorkingSet64 144547840 why

How do I get the lint level from a Visitor given a Block?

佐手、 提交于 2019-12-12 02:53:54
问题 For various reasons I use a Visitor for the HIR tree traversal instead of relying on the lint context to walk the tree. However, this means my lint ignores #[allow/warn/deny(..)] annotations in the source. How can I get this back? I know of ctxt.levels , but those don't appear to help. The other functions (like with_lint_attrs(..) are private to the context. 回答1: Since there was no solution with the Rust we had, I created the necessary callbacks in Rustc: With tonight's nightly, our

Mercurial internals : Git subrepository status after aggressive permission change

a 夏天 提交于 2019-12-10 23:42:17
问题 Disclaimer : I'm not asking for a solution, a workaround or any kind of advice on how to do things, I'm just curious about the internals of Mercurial. I have a mercurial repository with some subrepository in it (Git and Mercurial). My repository and all subrepo are in a clean state (ie: hg st -S returns nothing). I do some aggressive permission changes at the root : chown www-data:www-data -R * Now, hg st -S returns each and every file of the Git subrepos (the Mercurial ones are still

Unit Testing using InternalsVisibleToAttribute requires compiling with /out:filename.ext?

时光怂恿深爱的人放手 提交于 2019-12-10 19:05:22
问题 In my most recent question: Unit Testing Best Practice? / C# InternalsVisibleTo() attribute for VBNET 2.0 while testing?, I was asking about InternalsVisibleToAttribute. I have read the documentation on how to use it, and everything is fine and understood. However, I can't instantiate my class Groupe from my Testing project. I want to be able to instantiate my internal class in my wrapper assembly, from my testing assembly. Any help is appreciated! EDIT #1 Here's the compile-time error I get

Nullable<int?> is not possible, Why not? [duplicate]

て烟熏妆下的殇ゞ 提交于 2019-12-10 10:31:22
问题 This question already has answers here : Why can't I write Nullable<Nullable<int>>? (5 answers) Closed 5 years ago . Excuse me if its a silly question, I am trying to get a better understanding of Nullable types in .Net. From what i notice from Microsoft source code (using ReSharper), I understand that Nullable is a struct and T needs to be a struct public struct Nullable<T> where T : struct Now, I tried to do something like this public struct CustomNullable<T> where T : struct { } public