Entries:
Comments:
Posts:

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

Discussions

Curt Nichols Curt Nichols No Silver Bullet
  • New Visual Studio UI

    , Blue Ink wrote

    @rhm: If they did that, chances are PWB would still be around.

    lol. Props for mentioning PWB. Smiley

  • Ideas for C# 5.0

    exoteric said:

    Open question. Should there be special support for this scenario?

     

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    namespace Test
    {
        class Program
        {
            static void Main(string[] args)
            {
                var s1 = Enumerable.Range(1, 10);
                var s2 = s1.Select(x => x - 10);
                var s3 = Enumerable.Empty<int>();
                try
                {
                    s3 = s1.Zip(s2, (a, b) => a / b);
                }
                catch (DivideByZeroException) // we'd like to catch the insect here
                {
                    Console.WriteLine("got it");
                }
                foreach (var x in s3) // but this is where it shows itself
                    Console.WriteLine(x);
                Console.ReadLine();
            }
        }
    }
    

     

    It's quite easy to build extension methods to catch and handle exceptions and chain these on a LINQ expression. It just doesn't follow the normal syntax for dealing with exceptions.

     

    Hmm...

    Hmm, well, that's the framework, not C#, but I think the issue here is accepting how enumerables work. If you really need to know right now that nothing will cause the enumerable to throw then do something to materialize it right now, like s1.Zip(...).ToArray(). Alternatively, because you know where the exception can happen just put your catch in the right place. Smiley

  • Flip MinoHD

    PaoloM said:
    dahat said:
    *snip*

    Mine was fine, the only issue I found is that it doesn't do any kind of shakycam compensation, so movies tend to be a bit nauseous sometimes Smiley

     

    I wonder if i should just build myself a ghetto steadycam...

    I mount mine on my camera tripod which weighs about 5.5 pounds. It helps considerably.

     

    EDIT: I should probably point out that I don't set the tripod on the ground, I use it as a handle with sufficient mass to smooth out motions with the Flip.

  • New C# Syntax  (methods)

    BitFlipper said:
    Sven Groot said:
    *snip*

    And what if you don't want the object disposed at the end of the scope, because you do want to store a reference somewhere?

     

    As I said, OnScopeExit is not related to the GC and it does not dispose the object in any way. Destructors in C++ are often used to perform syncing operations, not just resource cleanup. Just because an object goes out of the scope from where it was created does not mean the object cannot be referenced from anywhere else after the fact, or that it will stop functioning in any way (since OnScopeExit doesn't dispose anything).  This is more used in cases where you need to know exactly when the object goes out of scope from a certain block of code, similar to how you can do it with try/finally or "using" blocks, but without the extra lines of code.  Very useful when a block of code can exit from multiple places. Plus I don't see why this would add overhead since the compiler can check each object and only call OnScopeExit if the object actually overrode the default, empty OnScopeExit call.

     

    Edit: The logic is something like this:

    • Was new called on an object? If not, don't do anything further.
    • Did the object override OnScopeExit? If not, don't do anything further.
    • Create a hidden try/finally block (similar to how it is done for lock, using, etc)
    • In the finally block, call OnScopeExit for the object.

    So I don't see how this is any more complex than what is already done for lock and using, or how it is going to cause any kind of performance hit. if you don't override OnScopeExit, there is no extra code.

    Implementing your idea through a virtual method binds the behavior to every object of that type. This is seldom what we want for clean-up code. E.g., consider Stream. Sometimes I open a file and want to close it within the same function, other times I want it to outlive the current method. I would need two separate types for those behaviors.

     

    You've made the behavior an attribute of the type when in fact we want to control it according to the context in which we're using the instance. With your OnScopeExit if I wanted a FileStream that cleans itself up I would need to derive a new type. That's just not a good design.

     

    Not to pick on your idea, but try/finally is explicit. "using" is syntactic sugar, but still explicit. Trying to read code that used your scheme would require me to check whether the type I'm using has an override for OnScopeExit and to examine what it did. It's less readable.

     

    I don't see the benefit when C# already has "using."

  • Online Community Interview!!

    I like online communities such as [INSERT COMMUNITY NAME] because of the [INSERT ADJECTIVE] [INSERT NOUN], not to mention the great [INSERT NOUN] from [INSERT NOUN] like [INSERT PROPER NAME].

    [INSERT SIGNATURE]

    [INSERT EMOTICON]

  • Windows Vista inside out?

    Sven Groot said:
    Curt Nichols said:
    *snip*

    It was also apparently due in November. No wait, January. Sorry, I meant April. Amazon's release date for this book just keeps shifting so I've lost faith in it.

    Yeah, well, maybe I'll hold onto the 4th edition for a while. Smiley

  • Windows Vista inside out?

    Have you taken a look at Windows Internals? The 5th edition, apparently due this month, covers up through Vista and Server 2008. The 4th edition is about 900 pages of Windows' insides.

  • Bing is Live

    Shoe phone. Smiley

  • A Few Ideas: ANumber & "Branded" Types

    > Why didn't they also add the an arbitrary precision type as well?

    My take on this is a) you're not thinking like a business, and b) product teams don't have infinite resources, even at Microsoft--there are probably better things for them to spend their time on.

    I have seen Eric Lippert respond a number of times to the question "Why wasn't feature X implemented?" A couple of his public posts that touch on the topic: How many Microsoft employees does it take to change a lightbulb? and In Foof We Trust: A Dialogue.

    (Eric's blog covers many topics, and has some good series on immutability and covariance/contravariance. One could do a lot worse than to read his blog regularly.)

  • Wolfram Alpha

    stevo_ said:

    Units FTW. Smiley