Why do WinRT types have to be sealed?

Windows runtime objects exposed to JavaScript applications are sealed from a JavaScript perspective - you can't add expando properties to WinRT objects. But from C++ and C#, winrt objects can be inherited if the object supports inheritance (most Xaml classes support inheritance for instance, but most others don't) The reason that WinRT objects are sealed from JS is to ensure that the winrt object behave the same regardless of what the app has done - if an app redefines some function property on an object, it could cause other parts of the app to misbehave.

Windows runtime objects exposed to JavaScript applications are sealed from a JavaScript perspective - you can't add expando properties to WinRT objects. But from C++ and C#, winrt objects can be inherited if the object supports inheritance (most Xaml classes support inheritance for instance, but most others don't). The reason that WinRT objects are sealed from JS is to ensure that the winrt object behave the same regardless of what the app has done - if an app redefines some function property on an object, it could cause other parts of the app to misbehave.

Same restriction on C#, check at 40:15 in this video: channel9.msdn. Com/Events/BUILD/BUILD2011/TOOL-531T COM does not support implementation inheritance. – Hans Passant Sep 21 at 14:21 2 @Hans: This has absolutely nothing to do with COM.

The windows runtime is not COM (it has some elements of COM, but it's very different). The runtime DOES support inheritance - as Pavel mentioned above, you can derive from FrameWorkElement in C++/CX or C#/VB. – Larry Osterman Sep 21 at 14:34 I can't help but do the "derives from IUnknown, does reference counting: it must be duck" test.

Looking forward to you blogging about this. – Hans Passant Sep 21 at 14:49 @LarryOsterman: "if an app redefines some function property on an object, it could cause other parts of the app to misbehave" But that's true of any environment that supports virtual methods. Yes, it's possible for a descendant to screw things up, if their override fails to follow the contract.

That doesn't explain why JavaScript is only allowed to see sealed classes. – Joe White Sep 21 at 15:59 1 JavaScript isn't just allowed to see sealed classes. It's just that the only non-sealed classes in the are Xaml related and thus aren't exposed to JavaScript apps.

– Larry Osterman Sep 21 at 19:56.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions