Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. C# 3.0 Limitation: Type Inference & Lambda Expressions

C# 3.0 Limitation: Type Inference & Lambda Expressions

Scheduled Pinned Locked Moved C#
helpcsharplinqbeta-testingfunctional
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    SHaroz
    wrote on last edited by
    #1

    I saw an interesting point raised here: http://www.atrevido.net/blog/2007/08/02/C+Frustration.aspx[^] The C# 3 spec does not permit assigning a labmda expression to type infered value. So the following statement is invalid:

    var Add = (int a, int b) => a + b;

    The keyword var will give error CS0815, "Cannot assign 'lambda expression' to an implicitly typed local". If the type is changed from var to Func<int, int, int>, the error goes away. The type of this lambda expression is not ambiguous, so the error must simply be a limitation in the type inference. Does anyone know if Microsoft has plans to fix this issue? If the type is known and expressible as a variable, then I see no good reason why this variable should behave differently than any other type-infered generic variable. I ran into this problem while using VS2008 beta 1, so if it works in beta 2, please let me know. -sharoz

    O 1 Reply Last reply
    0
    • S SHaroz

      I saw an interesting point raised here: http://www.atrevido.net/blog/2007/08/02/C+Frustration.aspx[^] The C# 3 spec does not permit assigning a labmda expression to type infered value. So the following statement is invalid:

      var Add = (int a, int b) => a + b;

      The keyword var will give error CS0815, "Cannot assign 'lambda expression' to an implicitly typed local". If the type is changed from var to Func<int, int, int>, the error goes away. The type of this lambda expression is not ambiguous, so the error must simply be a limitation in the type inference. Does anyone know if Microsoft has plans to fix this issue? If the type is known and expressible as a variable, then I see no good reason why this variable should behave differently than any other type-infered generic variable. I ran into this problem while using VS2008 beta 1, so if it works in beta 2, please let me know. -sharoz

      O Offline
      O Offline
      originSH
      wrote on last edited by
      #2

      Have you looked to see if this isssue has been raised on http://connect.microsoft.com[^]? Thats were bugs and suggestions are reported back to MS and where they give answers to those bugs and suggestions. If theres nothing there already about this you might want to submit some feedback and they *might* change it. If theres already feedback about it then you can show your support for it ... the more support for an issue, the more likely they are to do something about it.

      S 1 Reply Last reply
      0
      • O originSH

        Have you looked to see if this isssue has been raised on http://connect.microsoft.com[^]? Thats were bugs and suggestions are reported back to MS and where they give answers to those bugs and suggestions. If theres nothing there already about this you might want to submit some feedback and they *might* change it. If theres already feedback about it then you can show your support for it ... the more support for an issue, the more likely they are to do something about it.

        S Offline
        S Offline
        SHaroz
        wrote on last edited by
        #3

        I couldn't find any report for this problem, so I created one. https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=294156[^] Thanks for the advice. -sharoz

        O 1 Reply Last reply
        0
        • S SHaroz

          I couldn't find any report for this problem, so I created one. https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=294156[^] Thanks for the advice. -sharoz

          O Offline
          O Offline
          originSH
          wrote on last edited by
          #4

          And they've already replied :) Thanks for your feedback. We have reproduced this bug on Vista and OrcasBeta2VSTS, and we are sending this bug to the appropriate group within the Visual Studio Product Team for triage and resolution. Thank you, Visual Studio Product Team. Posted by Microsoft on 20/08/2007 at 02:24 of course this doesn't mean they'll defiantly do something about it ... but atleast they are looking at it :)

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups