POV-Ray : Newsgroups : povray.off-topic : C# 4.0 Default parameters : Re: C# 4.0 Default parameters Server Time
9 Oct 2024 16:07:59 EDT (-0400)
  Re: C# 4.0 Default parameters  
From: John VanSickle
Date: 5 Feb 2009 21:34:57
Message: <498ba1d1$1@news.povray.org>
nemesis wrote:
> Darren New escreveu:
>> Mike Raiford wrote:
>>> 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.
>>
>> No, i mean instead of
>>   job.print(orient:landscape, copies:2, paper:A4)
>> the suggestion it that it's much more OO to say
>>   job.initialize()
>>   job.orient(landscape)
>>   job.copies(2)
>>   job.paper(A4)
>>   job.print()
> 
> More OO, or more assemblyish?  I mean, you individually feed the stack 
> and then call a function using those arguments already in the stack. ;)

Some class designers would make most of the member functions in class 
PrintJob return a reference to the class so that this could be one line:

job.initialize().orient(landscape).copies(2).paper(A4).print();

Of course, there would also be interminable debate about whether there 
should be an initialize() member in any C++ class, and I'm sure that 
some would want to override the streaming operator so that it could be 
used to feed some of the parameters to the PrintJob class.

Regards,
John


Post a reply to this message

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