473,795 Members | 2,954 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

C# Language Suggestions

Hello,

I understand that this is a good place to post suggestions
about future changes to the language, and that the
Microsoft developers who develop C# read this newsgroup.
If there is a more appropriate place to post this, please
let me know. So, here are a few things I'd like to see.

1. A way to declare a local variable as being readonly.

2. A way to define static variables that are only
accessible from within a given function, like in C++.
This is a nice form of information hiding, helps put
definitions near their use, and reduces clutter in the
class.
Andrew

Nov 15 '05
11 1996
>> (local readonly discussion)
I don't have any real comments here.
So What's the next step?

I don't agree. Local variables and class fields are very different beasts, with locals being associated with the function and instance ones associated with the instace (somehow that seems like a tautology).

Or, to put it another way, you can get the identical effect by using a class-level const/readonly as you could over one declared in the function. It would mean the same thing. It's really just a question of where you get to declare them.
(This part of the discussion was about function-static
variables, not "const/readonly" -- I guess you
meant "static" here instead of "const/readonly".)

As I understood it, the argument that was presented
against having function-static variables was: if some
thing X already can be done at the class level, then one
doesn't get anything new by having X be done locally in a
function. My point was that there is something wrong with
this argument because if one takes X="variable" then the
argument is claiming that nothing new is obtained by
having local variables (since one could use class fields
instead of local variables), and yet C# has local
variables.

Information hiding is the reason that I'm suggesting this
feature.

That would be the same as if it was declared as static to the class. My point is that it's easier if all the class-level variables are centralized rather than being spread out in various methods.
As I discussed, I do not agree that the case of a thread-
safe application is easier without function-static
variables, and I have not heard any other cases. So I
don't understand what it is that's easier if function-
static doesn't exist. My personal preference would be to
localize the information to get information hiding, not to
put all the information at a level where it's accessible
to entities that have no business accessing it.

The complexity argument is at least as important as this one, however. Since you can get the same effect with a class-level static, you don't need to have method-level statics, and we generally try not to add a feature that duplicates something that's already there.


I am happy that C# has gone in the direction of trying to
keep things simple. That is one of the things I like
about the language, and I would not want things to be
otherwise. The new capability that function-static would
add is a form of information hiding that is not present
with class-static variables. Simplicity is one design
criterion, and information hiding is another criterion,
and information hiding has precedent in C#, e.g., there
are no global variables, classes can have private and
protected variables, functions can have local variables,
and "for" and "foreach" variable scope is limited to the
loop. These things aren't functionally necessary, except
for local variables (which also provide information
hiding).

Nov 15 '05 #11
Andrew <as********@nos pam.onezero.org > wrote:
As I understood it, the argument that was presented
against having function-static variables was: if some
thing X already can be done at the class level, then one
doesn't get anything new by having X be done locally in a
function. My point was that there is something wrong with
this argument because if one takes X="variable" then the
argument is claiming that nothing new is obtained by
having local variables (since one could use class fields
instead of local variables), and yet C# has local
variables.


How exactly would you propose using class variables instead of local
variables? Bear in mind that:

o There may be multiple threads running a single method at a time
o A single thread may have recursively called the same method several
times

Presumably it would be possible to mimic local variables through the
use of ThreadStaticAtt ribute and storing everything within Stacks, etc
- but that's a far cry from the simplicity with which you can mimic
"method-local statics".

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 15 '05 #12

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

Similar topics

2
3180
by: R. Rajesh Jeba Anbiah | last post by:
I'm supposed to do a big portal with multi-language support and I'm decided to do my own instead of going for gettext. I have sort out few implementations; most of them uses global variables. I'm bit confused, how it will affect the performance. Right now, I use global variables in config file. Most of the experts in this group are ranting against global variable usage. I would like to know how would you handle such config settings (DB is...
12
1901
by: mpinsley | last post by:
We are a software company that provides Inventory & Procurement mangement to the hospitality industry. For the past twenty years we have been using Progress Software as both the development language and the underlying database. We are in the process of exploring new languages to write our application in, as Progress is becoming expensive for us. Here are some of our issues 1. Progress is a 4GL language so it is very rapid development....
16
1722
by: Ding Lei | last post by:
Dear fellows, I am currently a Java programmer, using it for around 3 years, & felt quite bored with it. IMHO, Java is too strict on lots of things, unlike Perl, There is usually only one or two way to do one thing with Java. Kinda of language I prefer is, elegant syntax, high-speed, wide usage, robust, great degree of freedom. I did learned C quite a long time ago, only a bit though. Not really sure is C the really language approriate?...
22
2883
by: Michael Nahas | last post by:
Antti & all interested, The draft description of my language to replace C is available at: http://nahas.is-a-geek.com/~mike/MyC.pdf I am a long time C programmer (I read the old testament in 1987) and I've tried to keep the spirit of C and make as few changes as possible. I was mostly driven by the bloat of C++ and, now, C99. I was also
2
1144
by: mpinsley | last post by:
We are a software company that provides Inventory & Procurement mangement to the hospitality industry. For the past twenty years we have been using Progress Software as both the development language and the underlying database. We are in the process of exploring new languages to write our application in, as Progress is becoming expensive for us. Here are some of our issues 1. Progress is a 4GL language so it is very rapid development....
7
4967
by: Robert Seacord | last post by:
The CERT/CC has just deployed a new web site dedicated to developing secure coding standards for the C programming language, C++, and eventually other programming language. We have already developed significant content for the C programming language that is available at: https://www.securecoding.cert.org/ by clicking on the "CERT C Programming Language Secure Coding Standard"
84
8599
by: aarklon | last post by:
Hi all, I found an interesting article here:- http://en.wikipedia.org/wiki/Criticism_of_the_C_programming_language well what do you guys think of this article....??? Is it constructive criticism that needs to be appreciated always...???
3
2078
Banfa
by: Banfa | last post by:
The project I work on has a bespoke hardware platform which is designed to go into a variety of different situations. However to keep things simple we really want the software for the platform to remain the same in all cases (as good practice suggests). One of our thoughts is that to provide the final customisation required for each application we could embed a scripting language into the platform to allow any additional business logic to be...
4
2324
by: edgy | last post by:
Hello, I am a beginner with PHP, and I have made a language switcher on a site that I am looking for your feedback on. First of all, the page is http://www.mankar.ca My question regarding usage is - well, does it work? Can you continue browsing in your selected language? I am especially interested in people using an IE browser with a locale setting that is not english or french.
0
9673
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
9522
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
10003
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
9046
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...
1
7544
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
5440
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...
0
5566
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4114
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
2
3730
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.