Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 614369
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T18:06:17+00:00 2026-05-13T18:06:17+00:00

Based on my answer to this question , I want to check something on

  • 0

Based on my answer to this question, I want to check something on my understanding of the upcoming dynamic type for C# 4.

In this case, we have a collection that represents fields in a record pulled from an unknown database table. Older code (pre-.Net 4) requires such a collection hold items of type Object. Merits of a such a collection aside, I’m wondering about what happens when you change Object to dynamic.

On the one hand, I expect that since things for dynamic types are all worked out at runtime that everything should be just fine as long as the programmer doesn’t make any typos or mistakes about the expected type of a particular item in the collection.

On the other hand, I wonder about the word “all” in the previous sentence. Would the runtime perhaps cache results from the first time a dynamic property is accessed, causing subsequent calls using different types to fail?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T18:06:18+00:00Added an answer on May 13, 2026 at 6:06 pm

    Here’s a relevant bit from Sam’s blog that talks briefly about the caching policy.

    http://blogs.msdn.com/samng/archive/2008/10/29/dynamic-in-c.aspx

    The DLR checks a cache to see if the
    given action has already been bound
    against the current set of arguments.
    So in our example, we would do a type
    match based on 1, 2, and the runtime
    type of d. If we have a cache hit,
    then we return the cached result. If
    we do not have a cache hit, then the
    DLR checks to see if the receiver is
    an IDynamicObject. These guys are
    essentially objects which know how to
    take care of their own binding, such
    as COM IDispatch objects, real dynamic
    objects such as Ruby or Python ones,
    or some .NET object that implements
    the IDynamicObject interface. If it is
    any of these, then the DLR calls off
    to the IDO and asks it to bind the
    action.

    Note that the result of invoking the
    IDO to bind is an expression tree that
    represents the result of the binding.
    If it is not an IDO, then the DLR
    calls into the language binder (in our
    case, the C# runtime binder) to bind
    the operation. The C# runtime binder
    will bind the action, and will return
    an expression tree representing the
    result of the bind. Once step 2 or 3
    have happened, the resulting
    expression tree is merged into the
    caching mechanism so that any
    subsequent calls can run against the
    cache instead of being rebound.

    However, what Sam doesn’t mention is exactly what the cache miss policy is. There are two main cache-miss policies: (1) trigger a cache miss when the argument types change, (2) trigger a cache miss when the argument identities change.

    Obviously the former is far more performant; working out when we can cache based solely on type is tricky. A detailed exegesis of how all that logic works would take rather a long time; hopefully I or Chris or Sam will do a blog post on it one of these days.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Based on the response to this question: Why does C++ have header files and
Based on this question it appears that the default template for CheckStyle will allow
Based on this question I don't want to litter my ready stuff waiting for
I've seen this question asked before but it seems that the answer may be
I'm going to guess that the answer is no based on the below error
This question flows from the answer to: How does one set up multiple accounts
I'm new to C++, and I have a question that should be easy, but
i have a question about event based program performance. in my company we have
I am doing this to check and already use the variable of type number
I've seen this question posed once or twice before, but never with an answer

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.