Coffeehouse Thread

34 posts

Forum Read Only

This forum has been made read only by the site admins. No new threads or comments can be added.

Anders Interview next week: Ask Questions Here

Back to Forum: Coffeehouse
  • User profile image
    ktr

    Is there any update on the status of extension properties? Last I heard, they weren't going to be supported due to a lack of acceptable syntax.

    Would there ever be consideration for a syntax that allows declaration of extension methods/properties via a different kind of class definition?

    For example:

    // extension class
    // can only access public members of parent type
    // only methods and properties can be defined; no fields
    public extension class ListExtensions<T> : List<T> 
    {
    
      // extension method
      public int foo() 
      {
        /* ... */
        return this.size(); // this refers to any List<T> instance.
      }
    
      // extension property
      public int bar
      {
        get { /* ... */ return this.size(); }
        set { /* ... */ }
      }
    
    }

    I think it would be a nice thing to have. And in the future it would give any other additions to the "extension" concept a nice home.

  • User profile image
    ktr

    With the future addition of "compiler as a service" are there any plans for possible support for metaprogramming? Like possible IDE support for templating in a way that is integrated into the C# language itself?

    I think this would make the bar much lower for creating frameworks that are both dynamic and yet very performant as well.

  • User profile image
    mikebmcl

    Has the C# language team ever considered or would they consider adding a way to use custom logic with automatically implemented properties? As an example, I often find myself creating private fields that I don't particularly care about (and which I don't actually want to be accessible at all) just so I can implement a lock in a property or add some other code (e.g. updating another property when a condition is met) that I don't think merits a method. It would be really nice to be able to do away with those private fields and all of the errors they can introduce and just use a field that would be automatically generated by the compiler instead. Something along the lines of this:

    // In this example, the hypothetical contextual keywords
    // autoget and autoset would allow the token 'field' to 
    // become a contextual keyword. The keyword 'field' would
    // give access to a backing field which would be automatically
    // generated by the compiler for the property.
    
    private static readonly object _amountLock = new object();
    
    public static double Amount
    {
        autoget
        {
            lock (_amountLock)
            {
                return field;
            }
        }
        autoset
        {
            lock (_amountLock)
            {
                field = value;
            }
        }
    }

    -Mike

  • User profile image
    SteveRichter

    what does Anders think about dependency properties in WPF? I find them confusing and difficult to use. Esp when I have not written any WPF for a few months.  What is the case against building a "property changed notification facility" directly into the language?

        // the "signal property changed" clause after the method declaration tells the 
        // compiler to call the method whenever the value of the specific property is changed.
        // The name of the method does not matter.
        // The parameters passed to the method are the before change value of the property
        // and the current value.
        //
        // more than 1 method could be defined to be called when the value of the property
        // changes. 
        //
        // The goal being that you could bind to a property in xaml without having to wire
        // up a dependency property. The XAML compiler would create a "signal property changed"
        // method for its use to be signaled when the property value changes.
        private void CustomerNameChangedEventHandler( string wasValue, string newValue ) 
          : signal property changed Name_Of_Property_Here
        {
    
        }
    

  • User profile image
    Adam​Speight2008

    Wlll vb.net and C# ever have the ability to discriminate methods with the same input type signature but different return types.  It seems strange to me that you currently can not do this, as the required return where stated is known before the method is selected.

    Examples in C# & VB.net

    String MyMethod(Int x )
    {
    ' Method Body Code}
    Int MyMethod (Int x ){
    ' Method body code
    }
    
    
    Int xr = MyMethod(10); ' Calls second instance.
    String xs = MyMethod(10) ' Calls first Instance.

     

    Function MyMethod(x As Integer) As Integer
    ' Method Body Code
    End Function 
    
    Function MyMethod (x As Integer ) As String
    ' Method body code
    End Function
    
    
    Dim  xr As Integer = MyMethod(10); ' Calls first instance.
    Dim  xs As String = MyMethod(10) ' Calls Second Instance.

  • User profile image
    felix9

    one of the appreciated practice of .NET languages desige team is that they always have the tooling needs in mind, optimize the language for things like intelisense and refactoring etc. but TouchStudio guys have discovered that the touch UI or NUI has unique tooling needs, any thought on that front ?

    p.s. I guess charles will be very pleased since here is no question about the Async CTP Smiley

  • User profile image
    Charles

    , felix9 wrote

    p.s. I guess charles will be very pleased since here is no question about the Async CTP Smiley

    I'm surprised, not pleased or unpleased... Seems to me that a language feature like Async would attract more curiosity, but you ask whatever you want - that's the point of this! Smiley

    C

  • User profile image
    Adam​Speight2008

    @Charles

    In the interview with Lucian, about the Async Update. He mention that delegates were expensive.  With the appear and requiring Lambdas being more pervasive in sourcecode, because of various parts of the framework, Async, TPL, LINQ etc.

    Does this mean that work is being work to reduce this cost? ( the invoking a delegate?) 

     

    Idea: Couldn't the Compiler, compile the expression tree and also the compiled code some way into the build? (Like it does for closures.) Then expensive part is already done.

    These Pseudo-Lambdas then could be called lazily.  

  • User profile image
    rhm

    , Charles wrote

    *snip*

    I'm surprised, not pleased or unpleased... Seems to me that a language feature like Async would attract more curiosity, but you ask whatever you want - that's the point of this! Smiley

    C

    In F#, async is implemented in terms of a more general language facility that is also used to implement the F# equivalent of iterators. Mads and Anders have both spoken about how C# async is similar to C# iterators in implementation and yet they are both implemented as seperate hard-wired language constructs.

    Can you ask Anders if he considered implementing a more general language facility to use to implement async in terms of? A lot of people would like to see a system where compiler-as-a-service could be invoked at compile-time to perform these kinds of transformations.

  • User profile image
    exoteric

    Questions

    • [Async] When is Async not appropriate to use?
    • [Async] Are there scenarios you'd like async to support but don't think it will/can?
    • [Async] Is there a need to optimize performance for some features for Async to be feasible in some scenarios? Delegates?
    • [Async] How long before the Async T-virus has permeated through all of .NET?
    • [Async] What is the most problematic aspect of implementing Async?
    • Do you forsee a C# spin-off with the application of hindsight? - Language-level refactoring.
    • Do you forsee more Skunkworks-like projects such as Cw that will influence the future of C#?
    • Would you like more support from the CLR for some features? If so, then which ones?
    • What are your favourite languages besides C#?
    • What inspires you?
    • What emerging features makes you go hmm...?
    • What are your favourite language features?
  • User profile image
    spottedmah

    I wish I "vote" for the posts I'm interested in.  For example @Bas makes a good point, I'd like to hear that topic discussed but there is no way for me to "Like" or "Vote" for it.  MD.

  • User profile image
    SteveRichter

    can static methods be made to obey the laws of inheritance? Currently the static methods of an abstract base class cannot be marked as override, virtual or abstract.

    How do static methods and fields of a class work? Does the compiler instantiate an object from the class and reserve that object as the holder of the static values?

  • User profile image
    aL_

    Anders,

    • What do you think about expanding the c# event syntax for better composability/interop with things like async/Rx?
    • Lucian mentioned tooling support for async, can you give some broad idea on whats going on there?
    • i'd also like to bump steves question about dependecy properties, do you think there should be more language support for that?
    • What features would you like to remove from c# as it is today?

     

  • User profile image
    Ian2

    Anders - more of a personal question - When considering technical content how much do you keep on tap in your head and how much is just a pointer to knowing where to look for something?  (With me it is probably 10% in my head, 50% knowing where to look and 40% 'haven't got a clue sir')

  • User profile image
    Charles

    This went great! Almost all of your questions were asked Smiley Since some were closely related, only one or two were left unasked (I decided to skip them since there were others more related to Anders' expertise and experience).

    Thank you for asking such great questions, Niners! Look for the conversation to appear on C9 next week.

    Best,

    C

  • User profile image
    Charles

Conversation locked

This conversation has been locked by the site admins. No new comments can be made.