www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Keyword 'dynamic' of C#4

reply bearophile <bearophileHUGS lycos.com> writes:
A pair of short posts that show the "dynamic" keyword of C#4:

http://www.codethinked.com/post/2008/10/28/C-40-New-Features-Part-1-dynamic-keyword.aspx

http://www.codethinked.com/post/2008/10/28/C-40-New-Features-Part-11-dynamic-keyword-second-look.aspx

Bye,
bearophile
Apr 27 2009
parent reply "Unknown W. Brackets" <unknown simplemachines.org> writes:
I read until I hit this:

    4.     if (<Main>o__SiteContainer0.<>p__Site1 == null)

And I was suddenly hit with a huge feeling of "I'm glad D doesn't look 
like this."  Seriously, I hope this is some sort of decompiled syntax 
and not actually valid.

I wonder what the overhead times were.  He should've timed them both and 
listed them separately.  For example, is DynamicMethod a complete win, 
or is the dynamic keyword cheaper as far as base cost?

This reminds me of the opDotExp discussion.  I can see that caching the 
cost could potentially be beneficial, as shown here.  That's the main 
offshoot I get from it.

-[Unknown]


bearophile wrote:
 A pair of short posts that show the "dynamic" keyword of C#4:
 
 http://www.codethinked.com/post/2008/10/28/C-40-New-Features-Part-1-dynamic-keyword.aspx
 
 http://www.codethinked.com/post/2008/10/28/C-40-New-Features-Part-11-dynamic-keyword-second-look.aspx
 
 Bye,
 bearophile

Apr 27 2009
next sibling parent Don <nospam nospam.com> writes:
Unknown W. Brackets wrote:
 I read until I hit this:
 
    4.     if (<Main>o__SiteContainer0.<>p__Site1 == null)
 
 And I was suddenly hit with a huge feeling of "I'm glad D doesn't look 
 like this."  Seriously, I hope this is some sort of decompiled syntax 
 and not actually valid.

Yeah. I've been worried that D is getting too complicated; I'm worried that it's lost too much of its original simplicity. But then I look at C#, and see a language that's well on the path to rival C++ in complexity, yet with a lot less power than D.
Apr 28 2009
prev sibling next sibling parent reply Christopher Wright <dhasenan gmail.com> writes:
Unknown W. Brackets wrote:
 I read until I hit this:
 
    4.     if (<Main>o__SiteContainer0.<>p__Site1 == null)
 
 And I was suddenly hit with a huge feeling of "I'm glad D doesn't look 
 like this."  Seriously, I hope this is some sort of decompiled syntax 
 and not actually valid.

It's decompiled: "This is where our friend Reflector comes in." It's also probably valid. However, no sane person would write that way, so it's not a huge issue. You can do similarly ugly things in D.
Apr 28 2009
parent "Unknown W. Brackets" <unknown simplemachines.org> writes:
Specifically, I'm concerned about ".<>".  What is that?  I guess it's a 
namespace, and so it's an empty one.  That just seems wrong... like D 
having "x..y" or "x.!()y", which it definitely doesn't have.

-[Unknown]


Christopher Wright wrote:
 Unknown W. Brackets wrote:
 I read until I hit this:

    4.     if (<Main>o__SiteContainer0.<>p__Site1 == null)

 And I was suddenly hit with a huge feeling of "I'm glad D doesn't look 
 like this."  Seriously, I hope this is some sort of decompiled syntax 
 and not actually valid.

It's decompiled: "This is where our friend Reflector comes in." It's also probably valid. However, no sane person would write that way, so it's not a huge issue. You can do similarly ugly things in D.

Apr 28 2009
prev sibling parent reply Benji Smith <dlanguage benjismith.net> writes:
Unknown W. Brackets wrote:
 I wonder what the overhead times were.  He should've timed them both and 
 listed them separately.  For example, is DynamicMethod a complete win, 
 or is the dynamic keyword cheaper as far as base cost?

Actually, he does. It's at the bottom of the "second look" post: Compile Time Bound: 6 ms Dynamically Bound with dynamic keyword: 45ms Dynamically Bound with MethodInfo.Invoke - 10943ms Dynamically Bound with DynamicMethod - 8ms --benji
Apr 28 2009
parent "Unknown W. Brackets" <unknown simplemachines.org> writes:
No, these are averages of run time.  These are not the upfront costs, 
but instead the average over 2 million calls or whatever.

For example, if DynamicMethod takes 20000ms upfront (to compile the il, 
although that seems way too long), it might still be smarter to use the 
dynamic keyword even in performance critical code.

-[Unknown]


Benji Smith wrote:
 Unknown W. Brackets wrote:
 I wonder what the overhead times were.  He should've timed them both 
 and listed them separately.  For example, is DynamicMethod a complete 
 win, or is the dynamic keyword cheaper as far as base cost?

Actually, he does. It's at the bottom of the "second look" post: Compile Time Bound: 6 ms Dynamically Bound with dynamic keyword: 45ms Dynamically Bound with MethodInfo.Invoke - 10943ms Dynamically Bound with DynamicMethod - 8ms --benji

Apr 28 2009