Re: static class inheritance, generalized



Ben Voigt [C++ MVP] wrote:

I'm trying to construct a compelling example of the need for a
language feature, with full support for generics, to introduce all
static members and nested classes of another type into the current
name search scope.

i.e. a very simple application would be

class ManyComputations
{
calling System.Math;

... z = Sin(3*x) + Log(y); // qualifiers not needed
}

This provides a superset of the "inherit from a static class"
concept, without actually using inheritance or conflicting with
"sealed".

All C# experts are invited to join the discussion over in
microsoft.public.dotnet.languages.vc in the thread titled "howto
decouple in .NET?" Some familiarity with C++/CLI is a definite plus.

I agree with Jon, THIS is the C# newsgroup and C# discussions should
be held here. We already have a truckload of offtopic (i.e. which are
more about .NET than C#) discussions here so more ONtopic discussion
here would be great ;)

What you're suggesting is IMHO running into problems very quickly.
With 'Sin' and 'Cos' you might not have duplicates in scope, but what
if you have?

Furthermore, the necessity which makes you want what you're suggesting
is the friction between procedural programming and OO programming: math
methods and calculation methods are typical procedural
methods/routines, which don't really fit into the OO paradigm, unless
you'd add Sin() as a method of an int or double for example.

As the language and framework (C#, .NET) are OO, the routines have to
be placed inside a class. To refer to the methods you now have to
specify in which class they're in. This can be a bit odd at first,
because you just want to call a routine like we all did in C or Pascal
and in these languages you also didn't have to specify in which file
the routine was in, it was just there as long as you'd #include the
header file.

However, if you would go the route of 'if I have included / imported a
header/namespace with solely routines and no classes, I should be able
to call them without specifying their location', you effectively
breaking down the OO nature of C# and will introduce what C++ also has:
a way to program C-style code, without classes.

Personally I think every static method has to be specified with the
class it's in. This is for clarity which method is called (so the
reader of the code can easily understand which method is called, a big
helper in getting bug rates down) and also to avoid duplicate names.

FB

--
------------------------------------------------------------------------
Lead developer of LLBLGen Pro, the productive O/R mapper for .NET
LLBLGen Pro website: http://www.llblgen.com
My .NET blog: http://weblogs.asp.net/fbouma
Microsoft MVP (C#)
------------------------------------------------------------------------
.



Relevant Pages

  • Re: Last Ninja Programming Language
    ... "You'll then have to write your own routines to deal with memory ... complete complimentary variable structure that mimics the regular BASIC ... "It's good for simple tasks, and as a beginner's language, but as an ... And REM was my friend. ...
    (comp.sys.cbm)
  • Re: Question about jumps
    ... Except you've missed the point that writing numeric I/O routines isn't ... in the book "The C programming language" where they solve ... Markus doesn't know *what* he wants to learn. ... You seem to assume that everyone is saying "printf will work for you ...
    (alt.lang.asm)
  • Re: Bounds checked arrays
    ... > more at each array access will not make any ... > this problem in the C language to do their dirty ... > When the state of this toggle is ON, the compiler ... > We have just to allow him/her to specify what to do ...
    (comp.lang.c)
  • Re: String filtering
    ... >>> language like Ada. ... You should specify what you wish to abstract away as unimportant ... If the language allows to do this in a consistent way, ... Purity requirement makes sense as an ...
    (comp.lang.ada)
  • Re: "Collatz 3n+1 conjecture is unprovable" paper
    ... The language is English. ... specify something in L bits that cannot be specified in fewer ... you add the bits needed to specify n the contradiction vanishes. ... "Theorem" There is no proof of FTA. ...
    (sci.math)