POV-Ray : Newsgroups : povray.off-topic : new C# stuff Server Time
5 Nov 2024 10:22:23 EST (-0500)
  new C# stuff (Message 1 to 10 of 43)  
Goto Latest 10 Messages Next 10 Messages >>>
From: Darren New
Subject: new C# stuff
Date: 21 Jan 2009 14:20:29
Message: <4977757d$1@news.povray.org>
http://weblogs.asp.net/scottgu/archive/2007/03/13/new-orcas-language-feature-extension-methods.aspx

You know, I've wanted something like this since the mid 80's. :-)
Much nicer (and more OO) than "friend" functions, IMO.

It looks like both WinForms and console .NET executables run under Linux 
with mono, too, without recompiling or anything. At least for sufficiently 
simple stuff.  (Ugly buttons etc on Linux, but that's probably a question of 
picking good styling.)

-- 
   Darren New, San Diego CA, USA (PST)
   "Ouch ouch ouch!"
   "What's wrong? Noodles too hot?"
   "No, I have Chopstick Tunnel Syndrome."


Post a reply to this message

From: nemesis
Subject: Re: new C# stuff
Date: 21 Jan 2009 14:34:07
Message: <497778af@news.povray.org>
Darren New escreveu:
>
http://weblogs.asp.net/scottgu/archive/2007/03/13/new-orcas-language-feature-extension-methods.aspx

> 
> 
> You know, I've wanted something like this since the mid 80's. :-)
> Much nicer (and more OO) than "friend" functions, IMO.

Orcs?  no, thanks!

Anyway, good to see C# does not merely milks away Delphi, Java and 
Python, but now also Ruby.

http://www.25hoursaday.com/weblog/2008/01/23/C30VsRubyThoughtsOnExtensionMethodsAndOpenClasses.aspx

Yes, it's very useful and dangerous too.  Side-effect-full, 
dynamically-typed imperative programming to the max!  Andrew would 
collapse just by looking at it... :)


Post a reply to this message

From: Kyle
Subject: Re: new C# stuff
Date: 21 Jan 2009 14:46:13
Message: <49777b85$1@news.povray.org>
I haven't read the whole article yet, only up to the first example, but 
am wondering why not just use a new class that inherits the string class 
and add an email check function there?  I'll finish the article later...


Post a reply to this message

From: Mike Raiford
Subject: Re: new C# stuff
Date: 21 Jan 2009 14:49:36
Message: <49777c50$1@news.povray.org>
Darren New wrote:
>
http://weblogs.asp.net/scottgu/archive/2007/03/13/new-orcas-language-feature-extension-methods.aspx

> 
> 
> You know, I've wanted something like this since the mid 80's. :-)
> Much nicer (and more OO) than "friend" functions, IMO.
> 
> It looks like both WinForms and console .NET executables run under Linux 
> with mono, too, without recompiling or anything. At least for 
> sufficiently simple stuff.  (Ugly buttons etc on Linux, but that's 
> probably a question of picking good styling.)
> 

Been using C# 3.0 for a while now. Not necessarily "new". That was so 
last year ;)

Anyway ... It is a neat feature, and with linq libraries brought in 
using 'using', it adds a ton of extensions to just about anything that 
implements IEnumberable, which is part of what makes linq work.

Cool feature, but with great power comes great responsibility...





-- 
~Mike


Post a reply to this message

From: Mike Raiford
Subject: Re: new C# stuff
Date: 21 Jan 2009 14:56:08
Message: <49777dd8$1@news.povray.org>
Kyle wrote:

> I haven't read the whole article yet, only up to the first example, but 
> am wondering why not just use a new class that inherits the string class 
> and add an email check function there?  I'll finish the article later...

Say, for instance you don't own the class you're extending and the class 
is sealed (you can no longer inherit) the function you want to add 
doesn't need the internals of the class, but would be convenient if it 
were part of the class. Or say you don't want to have to declare all 
strings that use your new method as 
KylesStuff.Coolthings.KylesCoolString you'd rather keep your existing 
codebase, and have this extension available to the new code that will be 
using it. Obviously a function that takes a KylesCoolString isn't going 
to accept a string, though you could create an implicit conversion, just 
to make things easier.

or, you simmply add an extension function to string, and not deal with 
the issues surrounding inheritance. The extension function simply acts 
as if it was there the whole time. A way of extending a class without 
messing with the class or creating a new class, if you will.

-- 
~Mike


Post a reply to this message

From: Darren New
Subject: Re: new C# stuff
Date: 21 Jan 2009 15:18:00
Message: <497782f8$1@news.povray.org>
nemesis wrote:
> Orcs?  no, thanks!

I think "Orca" is the code name for C# 2008 back in 2007. :-)

> Anyway, good to see C# does not merely milks away Delphi, Java and 
> Python, but now also Ruby.

Yep!  Except doing it with a strongly-typed component-friendly approach. :-)

You always could do it in Smalltalk, just like you do in Ruby. One advantage 
C# has is that you're not *actually* changing the string class; it's just 
syntactic sugar. It's more like a C++ friend, except with method/object syntax.

And if one library writes an "In()" function for collections, and another 
library writes an "In()" function for collections, there's no collision.

The problem with doing it in Smalltalk (or Ruby for that matter, I suspect) 
is that you wind up horking up any libraries that might have conflicts, and 
you wind up with workspaces that that can't share code.  (Indeed, the whole 
"workspace" concept in Smalltalk seems like a bad idea in hindsight, or at 
least extremely hard to manage in spite of all the help the environment 
gives you. :-)

-- 
   Darren New, San Diego CA, USA (PST)
   "Ouch ouch ouch!"
   "What's wrong? Noodles too hot?"
   "No, I have Chopstick Tunnel Syndrome."


Post a reply to this message

From: Darren New
Subject: Re: new C# stuff
Date: 21 Jan 2009 15:22:28
Message: <49778404$1@news.povray.org>
Kyle wrote:
> I haven't read the whole article yet, only up to the first example, but 
> am wondering why not just use a new class that inherits the string class 
> and add an email check function there? 

Because every function that currently returns a string doesn't have your 
extra code added. Every read from a file, every concatenation of two 
strings, every string literal, every element on a web page, every attribute 
from an XML file, every packet from a socket: all need to get converted to 
your type before you can use them.

The "email check" function might be a poor example.

Think of a "point" object, where you want to be able to calculate the 
distance, for example. Now you have rectangles holding points, windows 
holding rectangles, etc., and you have extra syntax to turn the points in 
the rectangles in the windows into MyPoint objects, just so you can apply 
the method. Or using a separate function unrelated to points and which 
doesn't show up in intelisense.

Plus, of course, that doesn't work if for some reason you can't inherit from 
the object, like it being an integer or something.

-- 
   Darren New, San Diego CA, USA (PST)
   "Ouch ouch ouch!"
   "What's wrong? Noodles too hot?"
   "No, I have Chopstick Tunnel Syndrome."


Post a reply to this message

From: Darren New
Subject: Re: new C# stuff
Date: 21 Jan 2009 15:25:26
Message: <497784b6$1@news.povray.org>
Mike Raiford wrote:
> Been using C# 3.0 for a while now. Not necessarily "new". That was so 
> last year ;)

Well, I haven't been using C# lately, so....

Too many people want Linux crap, and think they really *need* C++ to go as 
fast as possible, in spite interfacing to a MySQL server or some silliness.

> Anyway ... It is a neat feature, and with linq libraries brought in 
> using 'using', it adds a ton of extensions to just about anything that 
> implements IEnumberable, which is part of what makes linq work.

Cool. Any recommendations on good books for the stuff in C# 3 that's not in 
C# 2?  Lots of books, but hard to evaluate. :-) Any you found particularly 
good or bad?

-- 
   Darren New, San Diego CA, USA (PST)
   "Ouch ouch ouch!"
   "What's wrong? Noodles too hot?"
   "No, I have Chopstick Tunnel Syndrome."


Post a reply to this message

From: Mike Raiford
Subject: Re: new C# stuff
Date: 21 Jan 2009 16:23:06
Message: <4977923a$1@news.povray.org>
Darren New wrote:
> Mike Raiford wrote:
>> Been using C# 3.0 for a while now. Not necessarily "new". That was so 
>> last year ;)
> 
> Well, I haven't been using C# lately, so....
> 
> Too many people want Linux crap, and think they really *need* C++ to go 
> as fast as possible, in spite interfacing to a MySQL server or some 
> silliness.
> 

I had to tease, though ... :)

> 
> Cool. Any recommendations on good books for the stuff in C# 3 that's not 
> in C# 2?  Lots of books, but hard to evaluate. :-) Any you found 
> particularly good or bad?
> 

I haven't actually done a whole lot of reading, except for the 
documentation and online resources and working with it. There was a book 
being passed around here (Pro LINQ) that some people said was rather 
good, but I hadn't had a chance to look at it yet.



-- 
~Mike


Post a reply to this message

From: Nicolas Alvarez
Subject: Re: new C# stuff
Date: 21 Jan 2009 18:14:22
Message: <4977ac4e@news.povray.org>
Darren New wrote:
>
http://weblogs.asp.net/scottgu/archive/2007/03/13/new-orcas-language-feature-extension-methods.aspx
> 

Funny to see a post titled "*new* C# stuff" with a link to a March 2007 blog
post :)


Post a reply to this message

Goto Latest 10 Messages Next 10 Messages >>>

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.