Re: Problem with linker

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Default parameters introduce all kinds of problems, especially when overloading comes into
play. Suppose I have

class Someting {
public:
Something(LPCTSTR = NULL);
Something(int);
}

you would think there is no problem, but Something() is ambiguous.

C# handles this by providing multiple overloads, e.g.,
Something();
Something(string);
Something(int);

(take a look at the huge set of library calls with all the various combinations of
parameters). While it is a bit more difficult to write all the overloads, there is no
problem with future extensions creating ambiguities because of default parameters.

Deterministic finalization is fairly important, *especially* with a GC involved. Consider

SomeClass() { open file here, exclusive }
~SomeClass() { close file here }

void SomeFunction()
{
SomeClass();
.. do things
}

with nondeterministic finalization that is handled by the GC, the following sequence will
fail:
SomeFunction();
SomeFunction();

because the second call tries to open the file, which is already open, and isn't closed
until the GC discovers the object is no longer in use. When the only resource is memory,
nondeterministic finalization doesn't matter, but when external state is involved, which
is independent of memory, the temporal relationship matters a lot.
joe


On Thu, 07 Jun 2007 14:12:12 GMT, MrAsm <mrasm@xxxxxxx> wrote:

On Thu, 07 Jun 2007 10:37:38 GMT, "David Ching"
<dc@xxxxxxxxxxxxxxxxxxxxxx> wrote:

He's doing a great job with C# and .NET, IMHO.


He's a great guy. I think he generally did a great job with C#, but miss
some C++ things like default parameters (there are none), and the
deterministic finalization clearly missed the boat.

Hi David,

I think that, if C# should have default parameters (which can be a
good thing), I hope they do that like Ruby and not like C++ (because
the C++ way is somehow limited IMHO), e.g.:

<CODE language="Ruby"
url="http://www.wellho.net/resources/ex.php4?item=r104/llen2";>

# Note that you can default and
# calculate a value for a parameter
# in the method definition in Ruby

def ladlen(high, wide = high/4.0)
Math.sqrt(high * high + wide * wide)
end

</CODE>

For deterministic finalization, I think that with a garbage collector
there is less need for it than with C++. For "scarce" resources, I
think that 'using' could be OK.

MrAsm
Joseph M. Newcomer [MVP]
email: newcomer@xxxxxxxxxxxx
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
.



Relevant Pages

  • Re: Convert a string to a datetime using a pattern
    ... One of the overloads of DateTime.ParseExact does it: ... I wrote the above line from memory, it may have some error in the format, ... Prev by Date: ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Problem with linker
    ... I hope they do that like Ruby and not like C++ (because ... def ladlen ... For deterministic finalization, I think that with a garbage collector ...
    (microsoft.public.vc.mfc)
  • Re: Discovering variable types...
    ... > This is because X is actually stored in the executable's memory space ... You have a function similar to HeapSize: SizeOf. ... at compile time. ... All those overloads may be source-intensive, ...
    (comp.lang.pascal.delphi.misc)
  • Re: References to object
    ... That's because .NET doesn't use reference counters like COM did ... (deterministic finalization). ... .NET uses non-deterministic finalization ... it would be removed from memory. ...
    (microsoft.public.dotnet.framework)
  • Re: Is still math.h the C++ math library ?
    ... If my memory is right <cmath> includes also overloads for every ... using float instead of double. ...
    (comp.lang.cpp)