473,731 Members | 2,630 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

static class inheritance, generalized

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 ManyComputation s
{
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.publi c.dotnet.langua ges.vc in the thread titled "howto decouple in
..NET?" Some familiarity with C++/CLI is a definite plus.

Thanks.
Jun 5 '07 #1
49 5803
Ben Voigt [C++ MVP] <rb*@nospam.nos pamwrote:
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 ManyComputation s
{
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".
Because it's not actually inheritance, I'd try to avoid using the term
wherever possible.
All C# experts are invited to join the discussion over in
microsoft.publi c.dotnet.langua ges.vc in the thread titled "howto decouple in
.NET?" Some familiarity with C++/CLI is a definite plus.
I'll see if I've got time to join in.

One reason MS *might* want to do it - Java has it :)
The syntax used is quite nice, too - static import. The equivalent
would be static using:

static using System.Math;

I wouldn't suggest doing it within a class though - I'd put it with the
rest of the using statements.

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Jun 5 '07 #2

"Jon Skeet [C# MVP]" <sk***@pobox.co mwrote in message
news:MP******** *************@m snews.microsoft .com...
Ben Voigt [C++ MVP] <rb*@nospam.nos pamwrote:
>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 ManyComputation s
{
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".

Because it's not actually inheritance, I'd try to avoid using the term
wherever possible.
>All C# experts are invited to join the discussion over in
microsoft.publ ic.dotnet.langu ages.vc in the thread titled "howto decouple
in
.NET?" Some familiarity with C++/CLI is a definite plus.

I'll see if I've got time to join in.

One reason MS *might* want to do it - Java has it :)
The syntax used is quite nice, too - static import. The equivalent
would be static using:

static using System.Math;

I wouldn't suggest doing it within a class though - I'd put it with the
rest of the using statements.
Oh, it has to be available in a class. Absolutely positively. But I've
already explained why in the other group. That's not to say it wouldn't be
nice if it also worked at namespace scope.
>
--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too

Jun 5 '07 #3
Ben Voigt [C++ MVP] <rb*@nospam.nos pamwrote:
I wouldn't suggest doing it within a class though - I'd put it with the
rest of the using statements.

Oh, it has to be available in a class. Absolutely positively. But I've
already explained why in the other group. That's not to say it wouldn't be
nice if it also worked at namespace scope.
It looks like we're talking about *completely* different things. The
example you gave of being able to use the Sin and Log methods without
further qualification are very different from the desires you have in
expressed in the VC group, as far as I understand them (which isn't
terribly far).

For the purposes of making static members from one type available in
another type without qualification, adding the capability to using
statements is fine.

I'm not *entirely* sure what you're asking for in the VC group, but it
seems to extend *way* past that.

I think it would be a much more fruitful discussion here than in the
C++ group - and more on-topic too, if you're suggesting a C# feature
rather than a C++ feature.

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Jun 5 '07 #4
"Jon Skeet [C# MVP]" <sk***@pobox.co mwrote:
Ben Voigt [C++ MVP] <rb*@nospam.nos pamwrote:
For the purposes of making static members from one type available in
another type without qualification, adding the capability to using
statements is fine.
As I pointed out in the C++ thread, C# 3.0 does have this exact feature -
they're called Extension Methods.

http://blogs.msdn.com/abhinaba/archi...15/467926.aspx
http://msdn2.microsoft.com/en-us/lib...cs3spec_topic3

--
Chris Mullins, MCSD.NET, MCPD:Enterprise , Microsoft C# MVP
http://www.coversant.com/blogs/cmullins
Jun 5 '07 #5
Chris Mullins [MVP] <cm******@yahoo .comwrote:
For the purposes of making static members from one type available in
another type without qualification, adding the capability to using
statements is fine.

As I pointed out in the C++ thread, C# 3.0 does have this exact feature -
they're called Extension Methods.

http://blogs.msdn.com/abhinaba/archi...15/467926.aspx
http://msdn2.microsoft.com/en-us/lib...cs3spec_topic3
It's not that *exact* feature. For one thing, it doesn't apply to
existing methods. For another, it makes them appear to be instance
methods. I certainly wouldn't want to call x.Sin() + y.Cos() in my code
- I'd much rather be able to use Cos(x) + Sin(y).

It may well go part of the way though, in many cases.

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Jun 5 '07 #6

"Chris Mullins [MVP]" <cm******@yahoo .comwrote in message
news:O9******** ******@TK2MSFTN GP02.phx.gbl...
"Jon Skeet [C# MVP]" <sk***@pobox.co mwrote:
>Ben Voigt [C++ MVP] <rb*@nospam.nos pamwrote:
>For the purposes of making static members from one type available in
another type without qualification, adding the capability to using
statements is fine.

As I pointed out in the C++ thread, C# 3.0 does have this exact feature -
they're called Extension Methods.
Your post in the C++ thread got recalled before I could look at it. I was
looking forward to hearing your input, too.
>
http://blogs.msdn.com/abhinaba/archi...15/467926.aspx
http://msdn2.microsoft.com/en-us/lib...cs3spec_topic3

--
Chris Mullins, MCSD.NET, MCPD:Enterprise , Microsoft C# MVP
http://www.coversant.com/blogs/cmullins

Jun 5 '07 #7
"Ben Voigt [C++ MVP]" <rb*@nospam.nos pamwrote
Your post in the C++ thread got recalled before I could look at it. I was
looking forward to hearing your input, too.
My post got recalled? How... unexpected. I wonder how that happened.

I can see it in Google Groups, for what it's worth...

--
Chris Mullins, MCSD.NET, MCPD:Enterprise , Microsoft C# MVP
http://www.coversant.com/blogs/cmullins
Jun 5 '07 #8
"Jon Skeet [C# MVP]" <sk***@pobox.co mschrieb
The equivalent
would be static using:

static using System.Math;
Hi Jon,

why the keyword static here, why not simply:

using System.Math;

Christof
Jun 6 '07 #9
On Jun 6, 8:07 am, "Christof Nordiek" <c...@nospam.de wrote:
"Jon Skeet [C# MVP]" <s...@pobox.com schriebThe equivalent
would be static using:
static using System.Math;

why the keyword static here, why not simply:

using System.Math;
I suppose that would be okay in C# (in Java you can individually
import classes, not just packages). However, given that it's not doing
*quite* the same thing as normal using directive, I think I'd prefer
the extra "static" to make it more obvious to the reader. If you're
dealing with some unfamiliar libraries, it may not be immediately
clear whether a particular name is a namespace or a class.

Jon

Jun 6 '07 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
2000
by: Tim Van Wassenhove | last post by:
Hello, When i read the CLI spec, 8.10.2 Method inheritance i read the following: "A derived object type inherits all of the instance and virtual methods of its base object type. It does not inherit constructors or static methods...." In the C# spec, 17.2.1 Inheritance i read the following:
0
8943
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8770
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9301
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9229
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9176
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8184
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6030
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4543
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3257
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.