﻿<?xml version="1.0" encoding="utf-8"?><rss version="2.0"><channel><title>Ayende @ Rahien</title><link>http://ayende.com</link><description>Ayende @ Rahien</description><copyright>Copyright (C) Ayende Rahien  2004 - 2021 (c) 2026</copyright><ttl>60</ttl><item><title>Stanislav Ageev commented on Dynamic resolution rules joy</title><description>Darius is right, __getattr__ in Python got exactly the same behavior which makes sense. I was missing this behavior a lot</description><link>http://ayende.com/119809/dynamic-resolution-rules-joy#comment24</link><guid>http://ayende.com/119809/dynamic-resolution-rules-joy#comment24</guid><pubDate>Tue, 25 Oct 2011 15:57:24 GMT</pubDate></item><item><title>Chris Marisic commented on Dynamic resolution rules joy</title><description>I think  JC summed up this post, that the method is named very poorly.

That if the method was named TryGetMissingMember that the intent would be conveyed properly.</description><link>http://ayende.com/119809/dynamic-resolution-rules-joy#comment23</link><guid>http://ayende.com/119809/dynamic-resolution-rules-joy#comment23</guid><pubDate>Mon, 24 Oct 2011 13:54:20 GMT</pubDate></item><item><title>Darius Damalakas commented on Dynamic resolution rules joy</title><description>Standard behaviour, if I remember correctly, Python does exactly the same, and that makes perfect sense</description><link>http://ayende.com/119809/dynamic-resolution-rules-joy#comment22</link><guid>http://ayende.com/119809/dynamic-resolution-rules-joy#comment22</guid><pubDate>Sun, 23 Oct 2011 08:06:37 GMT</pubDate></item><item><title>Omri commented on Dynamic resolution rules joy</title><description>I believe the confusion comes from prior experience with Dynamic Proxies. one should understand that dynamic proxies and dynamic object are different. the behavior you are expecting is very reasonable in a dynamic proxy scenario. it is less reasonable in a dynamic object.</description><link>http://ayende.com/119809/dynamic-resolution-rules-joy#comment21</link><guid>http://ayende.com/119809/dynamic-resolution-rules-joy#comment21</guid><pubDate>Sat, 22 Oct 2011 18:10:47 GMT</pubDate></item><item><title>Nick Parker commented on Dynamic resolution rules joy</title><description>Seems fitting that it would infer the explicit assignment first, then fall through to an implicit when unavailable.</description><link>http://ayende.com/119809/dynamic-resolution-rules-joy#comment20</link><guid>http://ayende.com/119809/dynamic-resolution-rules-joy#comment20</guid><pubDate>Sat, 22 Oct 2011 17:43:53 GMT</pubDate></item><item><title>Jon commented on Dynamic resolution rules joy</title><description>Agree with Michael. This is the behavior I would expect.
</description><link>http://ayende.com/119809/dynamic-resolution-rules-joy#comment19</link><guid>http://ayende.com/119809/dynamic-resolution-rules-joy#comment19</guid><pubDate>Fri, 21 Oct 2011 19:54:32 GMT</pubDate></item><item><title>JC commented on Dynamic resolution rules joy</title><description>Maybe the method should have been named TryGetMissingMember instead hence avoiding any confusion about it's functionality.</description><link>http://ayende.com/119809/dynamic-resolution-rules-joy#comment18</link><guid>http://ayende.com/119809/dynamic-resolution-rules-joy#comment18</guid><pubDate>Fri, 21 Oct 2011 17:06:52 GMT</pubDate></item><item><title>Michael L Perry commented on Dynamic resolution rules joy</title><description>This is standard behavior for any dynamic language. Smalltalk's doesNotUnderstand is only called if the object is sent a message that it does not understand. Ruby's method_missing is only called when a method is truly missing. I think it would be more annoying if .NET were to choose the opposite default.</description><link>http://ayende.com/119809/dynamic-resolution-rules-joy#comment17</link><guid>http://ayende.com/119809/dynamic-resolution-rules-joy#comment17</guid><pubDate>Fri, 21 Oct 2011 16:21:02 GMT</pubDate></item><item><title>Jamie commented on Dynamic resolution rules joy</title><description>It seems like what you want is to use the dynamic behavior to essentially override a default value for some property: the only time you want to get the actual property value would be if nothing had been assigned. So the "setter" seems quite pointless if you expect the dynamic behavior to take precedence.

So why not just create a default dynamic value instead of a property? E.g. in your constructor just call TrySetMember to add some default for a dynamic value, instead of hardcoding a property that you want to allow to be overridden.




I think this makes sense, but if you don't like it, then just implement your own IDynamicMetaObjectProvider.


</description><link>http://ayende.com/119809/dynamic-resolution-rules-joy#comment16</link><guid>http://ayende.com/119809/dynamic-resolution-rules-joy#comment16</guid><pubDate>Fri, 21 Oct 2011 14:44:14 GMT</pubDate></item><item><title>Frank Quednau commented on Dynamic resolution rules joy</title><description>Just proves that however logical an API appears to be, there is always someone who doesn't like it the way it is. I like that as a sort of comforting start of weekend thought.</description><link>http://ayende.com/119809/dynamic-resolution-rules-joy#comment15</link><guid>http://ayende.com/119809/dynamic-resolution-rules-joy#comment15</guid><pubDate>Fri, 21 Oct 2011 13:59:01 GMT</pubDate></item><item><title>Bill Barry commented on Dynamic resolution rules joy</title><description>@zdeslav:

public override bool TryGetMember(GetMemberBinder binder, out object result) {
    if(binder.StaticInvoke!=null) return binder.StaticInvoke(out result);
}

Still I think the current design is better, but it wouldn't have to be as bad as you are assuming.</description><link>http://ayende.com/119809/dynamic-resolution-rules-joy#comment14</link><guid>http://ayende.com/119809/dynamic-resolution-rules-joy#comment14</guid><pubDate>Fri, 21 Oct 2011 13:34:43 GMT</pubDate></item><item><title>Lee Atkinson commented on Dynamic resolution rules joy</title><description>I think the confusion lies in that people assume that the dynamic keyword and the DynamicObject type are somewhat related - they aren't (they just happen to be used together lots of times).

It makes sense to me that you get the 'statically-defined' member rather than the result of TryGetMember. It most closely resembles 'normal' inheritance - start with the object and work up the inheritance tree until you find member you are looking for.

(The dynamic keyword just kets you late-bind to the object and thus make it 'more readable' as a simple member.)</description><link>http://ayende.com/119809/dynamic-resolution-rules-joy#comment13</link><guid>http://ayende.com/119809/dynamic-resolution-rules-joy#comment13</guid><pubDate>Fri, 21 Oct 2011 12:35:03 GMT</pubDate></item><item><title>zdeslav commented on Dynamic resolution rules joy</title><description>seems completely logical to me. Imagine:

public class Stupid : DynamicObject
{
    public int Age { get; set; }
    public int OtherProperty { get; set; }
    public int AndAnother { get; set; }
    ...

    public override bool TryGetMember(GetMemberBinder binder, out object result)
    {
        // if this would have precedence over the specified properties
        // here you would have to filter all of those properties
        // that would render explicit properties quite useless
        // if(binder.Name == "Age" ...
    }
}
</description><link>http://ayende.com/119809/dynamic-resolution-rules-joy#comment12</link><guid>http://ayende.com/119809/dynamic-resolution-rules-joy#comment12</guid><pubDate>Fri, 21 Oct 2011 12:00:35 GMT</pubDate></item><item><title>flukus commented on Dynamic resolution rules joy</title><description>I've never used dynamic object at all, nor read much about it.

Intuitively I would expect the getter t8o take precedence.</description><link>http://ayende.com/119809/dynamic-resolution-rules-joy#comment11</link><guid>http://ayende.com/119809/dynamic-resolution-rules-joy#comment11</guid><pubDate>Fri, 21 Oct 2011 11:49:55 GMT</pubDate></item><item><title>Bogdan Marian commented on Dynamic resolution rules joy</title><description>Reading the MSDN link for DynamicObject.TryGetMember (http://msdn.microsoft.com/en-us/library/system.dynamic.dynamicobject.trygetmember.aspx), I found this inside the remarks block: "You can also add your own members to classes derived from the DynamicObject class. If your class defines properties and also overrides the TrySetMember method, the dynamic language runtime (DLR) first uses the language binder to look for a static definition of a property in the class. If there is no such property, the DLR calls the TrySetMember method.". So, the behaviour encountered inside the code above seems to be the correct one and is similar to the one described by the official documentation.</description><link>http://ayende.com/119809/dynamic-resolution-rules-joy#comment10</link><guid>http://ayende.com/119809/dynamic-resolution-rules-joy#comment10</guid><pubDate>Fri, 21 Oct 2011 11:14:40 GMT</pubDate></item><item><title>Frederico Pinto commented on Dynamic resolution rules joy</title><description>This comes from the "Remarks" section of the MSDN article on TryGetMember:

"You can also add your own members to classes derived from the DynamicObject class. If your class defines properties and also overrides the TrySetMember method, the dynamic language runtime (DLR) first uses the language binder to look for a static definition of a property in the class. If there is no such property, the DLR calls the TrySetMember method."

3 it is... or am I missing something?</description><link>http://ayende.com/119809/dynamic-resolution-rules-joy#comment9</link><guid>http://ayende.com/119809/dynamic-resolution-rules-joy#comment9</guid><pubDate>Fri, 21 Oct 2011 11:13:59 GMT</pubDate></item><item><title>Khalid Abuhakmeh commented on Dynamic resolution rules joy</title><description>I find that quite annoying as well, that if I want to use a dynamic object's property I have to cast it before passing it into any method. In my eyes that defeats the purpose of using a dynamic to begin with since it has that additional development overhead/noise. 

Maybe they can fix it in the next .Net where it can inspect the parameter type of the method and just try to do a best guess auto-cast.</description><link>http://ayende.com/119809/dynamic-resolution-rules-joy#comment8</link><guid>http://ayende.com/119809/dynamic-resolution-rules-joy#comment8</guid><pubDate>Fri, 21 Oct 2011 11:09:59 GMT</pubDate></item><item><title>Bogdan Marian commented on Dynamic resolution rules joy</title><description>@Ayende I find this behaviour normal. The notion of TryXXX (found when parsing numbers or getting stuff out of dictionaries) is related to uncertainty. Thus, if the CLR sees a getter, it should call that getter and not call the TryGetMember method.</description><link>http://ayende.com/119809/dynamic-resolution-rules-joy#comment7</link><guid>http://ayende.com/119809/dynamic-resolution-rules-joy#comment7</guid><pubDate>Fri, 21 Oct 2011 11:08:42 GMT</pubDate></item><item><title>Mix commented on Dynamic resolution rules joy</title><description>MSDN article on TryGetMember is completely misleading - had I read it before posting my comment I would've expected 1 indeed.</description><link>http://ayende.com/119809/dynamic-resolution-rules-joy#comment6</link><guid>http://ayende.com/119809/dynamic-resolution-rules-joy#comment6</guid><pubDate>Fri, 21 Oct 2011 11:05:46 GMT</pubDate></item><item><title>Matt commented on Dynamic resolution rules joy</title><description>Seems perfectly reasonable to me. I'd consider it stupid if it had printed 1.</description><link>http://ayende.com/119809/dynamic-resolution-rules-joy#comment5</link><guid>http://ayende.com/119809/dynamic-resolution-rules-joy#comment5</guid><pubDate>Fri, 21 Oct 2011 11:05:30 GMT</pubDate></item><item><title>Mix commented on Dynamic resolution rules joy</title><description>So what did you actually expect it to show? 3 is printed as I would've expected it.</description><link>http://ayende.com/119809/dynamic-resolution-rules-joy#comment4</link><guid>http://ayende.com/119809/dynamic-resolution-rules-joy#comment4</guid><pubDate>Fri, 21 Oct 2011 10:55:53 GMT</pubDate></item><item><title>tobi commented on Dynamic resolution rules joy</title><description>Because the whole point of dynamic is to get in control of the members that your object demonstrates to have.</description><link>http://ayende.com/119809/dynamic-resolution-rules-joy#comment3</link><guid>http://ayende.com/119809/dynamic-resolution-rules-joy#comment3</guid><pubDate>Fri, 21 Oct 2011 10:53:06 GMT</pubDate></item><item><title>sw commented on Dynamic resolution rules joy</title><description>Why should it go the slower route of dynamic/reflection when there is a simple fast property on the object?</description><link>http://ayende.com/119809/dynamic-resolution-rules-joy#comment2</link><guid>http://ayende.com/119809/dynamic-resolution-rules-joy#comment2</guid><pubDate>Fri, 21 Oct 2011 10:46:31 GMT</pubDate></item><item><title>tobi commented on Dynamic resolution rules joy</title><description>Never worked with the DLR but I believe that DynamicObject is not the lowest level of abstraction. Maybe you can overrride this stupid behavior by overriding DynamicMetaObject GetMetaObject and returning a more well-behaved object.</description><link>http://ayende.com/119809/dynamic-resolution-rules-joy#comment1</link><guid>http://ayende.com/119809/dynamic-resolution-rules-joy#comment1</guid><pubDate>Fri, 21 Oct 2011 10:30:30 GMT</pubDate></item></channel></rss>