Loading User Information from Channel 9

Something went wrong getting user information from Channel 9

Latest Achievement:

Loading User Information from MSDN

Something went wrong getting user information from MSDN

Visual Studio Achievements

Latest Achievement:

Loading Visual Studio Achievements

Something went wrong getting the Visual Studio Achievements


felix9 felix9 the cat that walked by itself
  • M#'s 'scoped' keyword brings RAII to C#

    well, I'll describe some other patent documents briefly here, in case anyone is interested:

    these patents described the immutable/isolated permission system in more details, with more complex scenarios

    these described M# features Uniform Memory Access and Type-Safe Type Casting, which enables managed code to access unmanaged memory directy without copy/marshalling, and helps to build high performance operating system in managed code

    these described how to write high performance device drives in managed code, and a user-mode driver framework.

    described the error/exception mechanism in M#.

     along with the one I quoted above

    there are 12 patents published in these batch, read them if you are curious about Midori/M# stuff :)

  • M#'s 'scoped' keyword brings RAII to C#

    recently, a bunch of patent applications authored by Midori/M# team were published. one of them is quite interesting:
    the authors are Joe Duffy/Jared Parsons/Alek Bromfield/Shon Katzenberger/Eugene Rozenfeld

    it basically introduced a 'scoped' modifier to C#.
    for help you to parse the messy patent text, I extraced some content here.

    first, the importance of scope control

    A major challenge in system programming is controlling access to resources. In object-oriented programming resources are exposed as objects. For efficient resource usage and memory allocation, it is important that resources do not live longer than intended by the code which owns the resource. Often, resources are provided for what is intended to be a finite duration of usage. However, in managed programming there is nothing stopping a component from storing away a resource indefinitely and hence arbitrarily extend its usage. For instance, the resource can be wrapped in such a way that the owner revokes useful access to the resource, but this at best leads to a runtime failure in the system. The principles described herein solve this problem by providing lifetime semantics into the type system and enforcing the restrictions at compile time.

    then, introducing scoped references

    A scoped reference is a value which limits the access of a reference to a particular scope. A scope is a method for assigning a lifetime to a concept like an object, code block or stack frame. A scoped reference can be associated with a scope that has a lifetime that is provably shorter than the item that owns the reference, but is not associated with a scope that is longer than the item that owns the reference. By managing these scopes, a guarantee that a scoped reference never lives beyond a certain point in the system may be obtained.

    three types of scopes

    There are three types of scopes that will be described herein by way of example only. These three types will now be described in order, the first being referred to herein as a "lexical scope", the second being referred to as a "stack frame scope", and the third being referred to as an "object relational scope". However, the broader principles are not limited to these particular scopes as the principles may apply to the tying of a reference lifetime to a lifetime of any other reference that has a finite lifetime.

    1, lexical scope

    The first kind is a lexical scope. This uses the C# notion of a block as a scope. Any given block is younger than the block in which it is nested and scoped references can be assigned into inner blocks. Any attempt to assign a reference outside of the defining block results in a compiler error. Consider the following pseudo-code example:

     scoped Widget outer;
     if (condition) {
     scoped Widget inner = outer; //ok
     outer = inner; // error

    There are two rules to consider. The above example illustrates one rule in that every scoped reference is associated with a scope, and references in a younger scope may not be used as if they were references in an older scope. In this example, the first assigned "scoped Widget inner=outer" is a proper assignment, since the variable "outer" is associated with an older scope than the scoped reference that it is assigned to in this assignment. Consider further the following pseudo-code example

     scoped Widget outer;
     if (condition) {
     Widget inner = outer; //error

    This example illustrates a second rule in that a reference may also be unscoped. Unscoped references are not associated with a scope, regardless of where they lexically occur in a program's text. Another way to think of unscoped is as the biggest possible scope. Therefore, unscoped references may be used as if they were scoped references, but not vice versa. In this example, the assignment of "Widget inner=outer" is not permitted, even though "inner" is in an unscoped variable. This is because the variable "inner" is an unscoped variable, while the variable "outer" is a scoped variable. Thus, in this example, a scoped variable "outer" is attempted to be used as though it was an unscoped variable, which is not permitted.

    2, stack frame scope

    The second kind of scope region deals strictly with object lifetime, and is referred to herein as "stack frame scope". This often lines up very closely with lexical scope but is tracking a different idea. Every stack frame represents a different scope with newer frames being younger than the ones that precede them. There is also the heap region which is older than every stack region. This scope tracking ensures that objects allocated on a given stack frame will never be stored into a frame which will outlive the frame in which they were allocated.

    3, object relational scope

    The third kind of scoped region is the object relational scope. This allows a reference to be scoped to a particular object instance. The resulting reference can live no longer than the object to which it is related. This is can be done even when the scoped region of the particular reference is unknown. For instance, consider the following pseudo-code example:

     class Container
      scoped(this) object m_field;
      public scoped(this) object GetField( )
     return m_field;

    In this example the value returned from GetField will be defined in the same scope as the object on which GetField was called. If the object has no scope associated with it, then the access to the returned value will likewise be unbounded.

    stack allocation !

    Besides control over resources, another advantage scoped references provide is the ability to efficiently allocate objects on the stack instead of the heap. Typically, a managed object will do the majority of its object allocations on the heap and let the garbage collector later collect the memory when it is no longer in use. This is often unacceptable in system programming where allocations are closely monitored and heap allocations are often forbidden. Scoped references allow us to guarantee an object is not referenced beyond a certain point in a program and the need to store into the heap is removed. Consider the following pseudo-code:

      scoped Widget widget = new Widget( );

    In this example, the Widget instance was allocated into a scoped reference location. This confines the use of the Widget value to the lexical scope containing the local named "widget". Upon exiting the scope, the value is guaranteed to be unaliased in the system and can be collected immediately. This allows us to safely execute this allocation on the stack and avoid unnecessary heap pollution. This mechanism also allows us to allocate lambdas and their associated closure objects verifiably on the stack.

    scoped types, with destructor !

    As stated previously, certain types in the system exist solely for resource management. They are intended to only be used in a scoped fashion and to do otherwise would constitute an invalid use of the resource. A cleanup routine is also commonly associated with these types (freeing a handle). This construct is formalized as a scoped type which has the following properties: 1) a scoped type can only be allocated into a scoped reference or a field of a scoped type, and 2) a scoped type can define a cleanup function which will be executed just before the value is out of scope. Additionally, because they are always used in a scoped fashion, a scoped type can always be allocated on the stack.

  • rename this place ....

    lets bring on bayesian analysis and machine learning ! (a)

  • http://www.​dotnetconf.​net/

    recordings goes here :)  http://channel9.msdn.com/Events/dotnetConf/2014

    and, some hopes:

    1, another preview of .NET Native, with some compiler optimizations implemented.

    2, info on WPF vNext

  • VS14 CTP available

    @CaRDiaK: for one thing, 2013=12, '14' = 2015 (maybe), and there is no 13. :P

  • Lang.NEXT 2014 is coming ... May 29-30

    ohh... now the sessions about Rust and Enso are officially gone ... :(

  • Lang.NEXT 2014 is coming ... May 29-30

    Ok then, here is a similiar talk by Brian Goetz http://www.techtalkshub.com/lambda-peek-hood/

  • Lang.NEXT 2014 is coming ... May 29-30

    Hmm.... I noticed a small thing, Alex Buckley'sm Java 8 Lambda talk is missing on C9 site, what happened ? I see Alex Buckley in th panel so he was there right ? Oracle has some concern like legal stuff ???

  • Lang.NEXT 2014 is coming ... May 29-30

    Too bad there is technical problem with the Rust talk, hope it can be recovered, :(
    or, maybe can be compensated by this one: https://air.mozilla.org/guaranteeing-memory-safety-in-rust/

    and ...... for those who like tech conferences videos, like me, here is all the videos from NDC Oslo 2014, and there are MANY interesting content: http://vimeo.com/channels/ndc2014/

    for example , here is a list of C++ sessions, very nice http://olvemaudal.com/2014/06/06/videos-cpp-track-ndc-2014/

    and there are very nice C#/.NET sessions as well, and many other topics, very interesting.

    Next event to watch: dotnetconf :D : http://channel9.msdn.com/Events/dotnetConf/2014

  • VS14 CTP available

    @cheong: Client Hyper-V is a feature for Windows >= 8