473,756 Members | 2,900 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 5808
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
2002
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
9456
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
9275
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
10034
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9843
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,...
1
7248
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6534
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
5142
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
3805
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
3
2666
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.