POV-Ray : Newsgroups : povray.off-topic : C# 4.0 Default parameters : Re: C# 4.0 Default parameters Server Time
6 Sep 2024 07:15:26 EDT (-0400)
  Re: C# 4.0 Default parameters  
From: Mike Raiford
Date: 4 Feb 2009 11:03:11
Message: <4989bc3f$1@news.povray.org>
Darren New wrote:
> Mike Raiford wrote:
>> http://tinyurl.com/bt268c
>>
>> Let me just say: About time! I get tired of writing a bunch of 
>> overloads to make parameters look like they're optional!
> 
> There are some who make good arguments against default parameters. 
> Basically, if it's a default parameter, it should be a separate method 
> call to set the value, because that's more OO.  E.g., if you have a 
> default parameter for printing that says whether it should be landscape 
> or portrait, that should be a value in the print-job instance, not a 
> parameter specified on every call.

That is how C# is now. Sometimes it would be nice just to have one 
function with defaults, rather than 3 overloads of the same function 
that simply delegate back to the "full featured" function.

> Sadly, C# syntax is starting to get really ugly. :-) I expect the 
> overloading rules will soon almost be as bad as C++.

Yep. Default parameters are a C thing.. :D Maybe that's why I like them...

>  > list.SearchForContacts(address="home", name="sam", age:30);
> 
> Heh. My first thought on seeing the syntax was "I bet I'd always be 
> messing that up and using = instead of :".
> 

I've never been very fond of the named arguments syntax. I'm sure some 
people love it. BTW, why are strings passed with "=" and numbers passed 
with ":"?


-- 
~Mike


Post a reply to this message

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