juan_gandhi: (Default)
[personal profile] juan_gandhi
I've been thinking lately... say, you are writing a pojo, and it is a good practice to have a good toString(), right? How about toJSON/fromJSON? seems like it would be a good idea to have it everywhere as well, what do you think?

Date: 2010-01-15 11:10 am (UTC)
wizzard: (Default)
From: [personal profile] wizzard
I mean, to resolve them through GetMethods on type specified with 'this' modifier in code :)

Date: 2010-01-15 11:20 am (UTC)
From: [identity profile] xeno-by.livejournal.com
This won't work. When desugaring extension invocations compiler knows about lexical context - current namespace and the list of "usings". When you perform late binding, you don't have such info.

There are several workarounds tho, but they depend on your particular business logic. E.g. you could hardcode namespaces to look extension methods in (via compile-time constants or via configuration). Another option would be reading PDBs and acquiring namespace info for the method you wish (tho this won't work for release builds). Well, you get the idea - all solutions to this problem are hacks that work only under certain circumstances.

Btw, because of this particular glitch DLR doesn't support extension methods.
Edited Date: 2010-01-15 11:21 am (UTC)

Date: 2010-01-15 11:23 am (UTC)
wizzard: (Default)
From: [personal profile] wizzard
I see. Maybe they'll encode it in IL at some time.

Date: 2010-01-15 11:33 am (UTC)
From: [identity profile] xeno-by.livejournal.com
By the way, this stuff with extension methods is a part of a global problem with C# 3.0 innovations. When used within LINQ scenarios, they play well and seem to be orthogonal additions to the language. But take a step aside - and you face all the ugliness.

Date: 2010-01-15 02:54 pm (UTC)
wizzard: (Default)
From: [personal profile] wizzard
hehe. c# 2.0 was basically a direct mapping to CLR capabilities, but c# 3.0 went beyond that, that's why the discrepancies

Profile

juan_gandhi: (Default)
Juan-Carlos Gandhi

May 2025

S M T W T F S
    1 2 3
456 7 8 9 10
11 121314151617
181920 21 222324
25 262728293031

Most Popular Tags

Page Summary

Style Credit

Expand Cut Tags

No cut tags
Page generated May. 28th, 2025 12:26 pm
Powered by Dreamwidth Studios