internals

Confusion about how a getchar() loop works internally

心不动则不痛 提交于 2019-11-27 08:16:47
问题 I've included an example program using getchar() below, for reference (not that anyone probably needs it), and feel free to address concerns with it if you desire. But my question is: What exactly is going on when the program calls getchar() ? Here is my understanding (please clarify or correct me): When getchar is called, it checks the STDIN buffer to see if there is any input. If there isn't any input, getchar sleeps. Upon wake, getchar checks to see if there is any input, and if not, puts

What is INT 21h?

99封情书 提交于 2019-11-27 03:36:11
问题 Inspired by this question How can I force GDB to disassemble? I wondered about the INT 21h as a concept. Now, I have some very rusty knowledge of the internals, but not so many details. I remember that in C64 you had regular Interrupts and Non Maskable Interrupts, but my knowledge stops here. Could you please give me some clue ? Is it a DOS related strategy ? 回答1: From here: A multipurpose DOS interrupt used for various functions including reading the keyboard and writing to the console and

How can I access the ListViewItems of a WPF ListView?

痞子三分冷 提交于 2019-11-27 02:12:04
问题 Within an event, I'd like to put the focus on a specific TextBox within the ListViewItem's template. The XAML looks like this: <ListView x:Name="myList" ItemsSource="{Binding SomeList}"> <ListView.View> <GridView> <GridViewColumn> <GridViewColumn.CellTemplate> <DataTemplate> <!-- Focus this! --> <TextBox x:Name="myBox"/> I've tried the following in the code behind: (myList.FindName("myBox") as TextBox).Focus(); but I seem to have misunderstood the FindName() docs, because it returns null .

Factors in R: more than an annoyance?

倾然丶 夕夏残阳落幕 提交于 2019-11-26 23:45:21
One of the basic data types in R is factors. In my experience factors are basically a pain and I never use them. I always convert to characters. I feel oddly like I'm missing something. Are there some important examples of functions that use factors as grouping variables where the factor data type becomes necessary? Are there specific circumstances when I should be using factors? Vince You should use factors. Yes they can be a pain, but my theory is that 90% of why they're a pain is because in read.table and read.csv , the argument stringsAsFactors = TRUE by default (and most users miss this

$provide outside config blocks

删除回忆录丶 提交于 2019-11-26 23:17:53
I'm certainly missing some fundamental point about the injector, but I fail to understand why exactly this angular.module('app').config(function ($provide) { ... }); and this angular.module('app').config(function ($injector) { $injector.invoke(function ($provide) { ... }); }); work as intended, while this app.run(function($provide) { ... }); will throw Error: [$injector:unpr] Unknown provider: $provideProvider <- $provide As follows from the above, config has some special relationship with providers, while run deals with instances, yet I'm unsure about the thing that makes config blocks so

What is [DllImport(“QCall”)]?

六眼飞鱼酱① 提交于 2019-11-26 19:21:52
问题 Many methods in the .Net library are implemented in native code. Those that come from the framework itself are marked with [MethodImpl(MethodImplOptions.InternalCall)] . Those that come from some unmanaged DLL are marked with [DllImport] (e.g. [DllImport("kernel32.dll")] ). So far nothing unusual. But while writing answer for another question, I discovered there are many methods marked with [DllImport("QCall")] . They seem to be internal implementation of .Net (e.g. GC._Collect() ). My

How do databases work internally? [closed]

我只是一个虾纸丫 提交于 2019-11-26 18:44:45
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 2 years ago . I've been working with databases for the last few years and I'd like to think that I've gotten fairly competent with using them. However I was reading recently about Joel's Law of Leaky Abstractions and I realised that even though I can write a query to get pretty much anything I

If Int32 is just an alias for int, how can the Int32 class use an int?

纵饮孤独 提交于 2019-11-26 18:43:12
Been browsing through .NET source code of .NET Framework Reference Source , just for fun of it. And found something I don't understand. There is a Int32.cs file with C# code for Int32 type. And somehow that seems strange to me. How does the C# compiler compile code for Int32 type? public struct Int32: IComparable, IFormattable, IConvertible { internal int m_value; // ... } But isn't this illegal in C#? If int is only an alias for Int32 , it should fail to compile with Error CS0523 : Struct member 'struct2 field' of type 'struct1' causes a cycle in the struct layout. Is there some magic in the

How does object_id assignment work?

前提是你 提交于 2019-11-26 18:35:59
I'm playing around with Ruby's .object_id and noticed that, in several sequential sessions of irb, I get these identical results: false.object_id // 0 true.object_id // 2 nil.object_id // 4 100.object_id // 201 In fact, every integer's object_id seems to be ((value * 2) + 1). On the other hand, a given string's object_id is never the same after exiting and re-running irb. This raises several questions for me: Is there a known scheme by which certain object_id s are determined? Are others basically random? The ids for true, false, and nil, aren't sequential. Is there a way to ask what object is

Practical uses for the “internal” keyword in C#

試著忘記壹切 提交于 2019-11-26 15:36:56
Could you please explain what the practical usage is for the internal keyword in C#? I know that the internal modifier limits access to the current assembly, but when and in which circumstance should I use it? Ash Utility or helper classes/methods that you would like to access from many other classes within the same assembly, but that you want to ensure code in other assemblies can't access. From MSDN (via archive.org): A common use of internal access is in component-based development because it enables a group of components to cooperate in a private manner without being exposed to the rest of