Well it could do ( implementation detail) but it doesnt
extends extends an existing class with additional method(s) without explicit subclassing/design-patterning/... -
you just provide the extension method you desire to augment a existing class.
The current implementation I think relies on the C# compiler to do this (.Net) cos the C# compiler also has that capability built in to support class extension ( slightly different syntax). Its just a codegen issue to convert from cobra syntax to the c# equivalent.
I believe it (C# compiler) does this by making a static class containing your extension methods each taking an instance of the type u r extending , code references to this extension method are caught by the C# compiler and mapped to the static class+method implementation.
Theres a description somewhere in the C# compiler/.Net doc if you're interested in tracking it down - I saw it somewhere and thought it was quite cool ( both capability it gives and implementation)
The cobra compiler could do this itself ( if it doesnt already) so for the Java BE where the
(Java) compiler doesnt have this capability/feature , the static method rewrite and codegen and catch-and-redirect will have to be hoisted up into the cobra compiler and done by it instead.
This will then support any other BE compiler in the same way.
The difference between existing extends and decorates/wraps/encloses proposal is that extends is more limited
It only allows adding new methods ( and maybe properties(?)), decorates can do this as well but can do a whole lot more.
Forums
Decorator idea
13 posts
• Page 2 of 2 • 1, 2
Re: Decorator idea
Oohhh, see I thought that since Cobra doesn't currently support using existing extension methods (like from Linq), it didn't generate any either. Many thanks for the explanation hops.
Here's some documentation from MSDN: http://msdn.microsoft.com/en-us/library ... 83977.aspx
I'll update the Wiki when I get a chance: http://cobra-language.com/trac/cobra/wi ... Extensions
Hey, maybe the java back-end could implement it with decorators
Here's some documentation from MSDN: http://msdn.microsoft.com/en-us/library ... 83977.aspx
I'll update the Wiki when I get a chance: http://cobra-language.com/trac/cobra/wi ... Extensions
Hey, maybe the java back-end could implement it with decorators
- nerdzero
- Posts: 286
- Location: Chicago, IL
Re: Decorator idea
+1 from me on the decorator idea.
bikeshed stuff:
+1 for the "is wrapped" syntax, or maybe 'tunnel' before or instead of 'var'
-1 for syntax on the class line. better on the vars imho.
but these don't really matter
the idea sounds like a major boiler plate saver. maybe useful for other things
bikeshed stuff:
+1 for the "is wrapped" syntax, or maybe 'tunnel' before or instead of 'var'
-1 for syntax on the class line. better on the vars imho.
but these don't really matter
the idea sounds like a major boiler plate saver. maybe useful for other things
Falun Dafa is Good.
Truth, Compassion, Forbearance is Good.
Truth, Compassion, Forbearance is Good.
- kobi7
- Posts: 82
- Location: Israel
13 posts
• Page 2 of 2 • 1, 2
Who is online
Users browsing this forum: No registered users and 26 guests