Two questions here:
1. Is there any particular reason why when using stackalloc, the code byte
*buffer = stackalloc byte[50]; works, but code like byte *buffer; buffer =
stackalloc byte[50]; is considered incorrect syntax? Was this an oversight,
a stylistic design, or is there a technical reason it won't work?
2. I was reading an older(circa 2000) question[1] posted to one of these
groups in which Eric Gunnerson mentions that the C# team was still talking
about a way to declare inlined arrays of base types in structures,
basically:
struct myStruct
{
int[5] fiveArrays; //5 ints all in a row in memory, obviously would need
better syntax
}
out of my own curiosity, has anything about this come up recently? Is the
team still considering it? Is something perhaps coming up(or is there
something there in 1.1 I've not managed to find?).
1. http://tinyurl.com/vi0s 6 2843
Daniel, 2. I was reading an older(circa 2000) question[1] posted to one of these groups in which Eric Gunnerson mentions that the C# team was still talking about a way to declare inlined arrays of base types in structures, basically: struct myStruct { int[5] fiveArrays; //5 ints all in a row in memory, obviously would need better syntax } out of my own curiosity, has anything about this come up recently? Is the team still considering it? Is something perhaps coming up(or is there something there in 1.1 I've not managed to find?).
It's planned for v2.0 (Whidbey), with the syntax
struct myStruct
{
fixed int fiveArrays[5];
}
Mattias
--
Mattias Sjögren [MVP] mattias @ mvps.org http://www.msjogren.net/dotnet/
Please reply only to the newsgroup.
"Mattias Sjögren" <ma************ ********@mvps.o rg> wrote in message
news:OY******** ******@TK2MSFTN GP09.phx.gbl... Daniel,
2. I was reading an older(circa 2000) question[1] posted to one of these groups in which Eric Gunnerson mentions that the C# team was still
talkingabout a way to declare inlined arrays of base types in structures, basically: struct myStruct { int[5] fiveArrays; //5 ints all in a row in memory, obviously would
needbetter syntax } out of my own curiosity, has anything about this come up recently? Is the team still considering it? Is something perhaps coming up(or is there something there in 1.1 I've not managed to find?).
It's planned for v2.0 (Whidbey), with the syntax
struct myStruct { fixed int fiveArrays[5]; }
Good to hear, I havn't had the time to read everything on the new C# specs.
Interestingly, this is one feature I never use but always miss.
Thanks
Mattias
-- Mattias Sjögren [MVP] mattias @ mvps.org http://www.msjogren.net/dotnet/ Please reply only to the newsgroup.
Daniel, Good to hear, I havn't had the time to read everything on the new C# specs.
IIRC the preliminary spec they published only covered the four new big
features (generics, partial types, iterators and anonymous delegates).
There are more little things being added as well. You can see them at
the end of Anders Hejlsberg's PDC slides (session TLS320) at http://msdn.microsoft.com/events/pdc...s/default.aspx
Interestingl y, this is one feature I never use but always miss.
It will probably mostly be used in interop situations. It's limited to
the primitive value types, and I believe it only works in an unsafe
context. There's no runtime support for it, so they implement it by
generating a nested opaque value type of size
sizeof(elementT ype)*numElement s, include a field of that type in place
of the fixed array, and then index into that with pointer offsets.
Mattias
--
Mattias Sjögren [MVP] mattias @ mvps.org http://www.msjogren.net/dotnet/
Please reply only to the newsgroup.
"Mattias Sjögren" <ma************ ********@mvps.o rg> wrote in message
news:ut******** ******@TK2MSFTN GP12.phx.gbl... Daniel,
Good to hear, I havn't had the time to read everything on the new C#
specs. IIRC the preliminary spec they published only covered the four new big features (generics, partial types, iterators and anonymous delegates). There are more little things being added as well. You can see them at the end of Anders Hejlsberg's PDC slides (session TLS320) at
http://msdn.microsoft.com/events/pdc...s/default.aspx
Hrmm, I find it interesting that there has been less coverage on some of
these minor features added to the language. the namespace alias qualifier
looks interesting, as does the addition of static classes. Every forum,
newsgroup, mailing list, etc I read has been up in arms over generics and
iterators, but they say very little about some of these other features that,
while not massive, are still interesting.Interestingl y, this is one feature I never use but always miss. It will probably mostly be used in interop situations. It's limited to the primitive value types, and I believe it only works in an unsafe context. There's no runtime support for it, so they implement it by generating a nested opaque value type of size sizeof(elementT ype)*numElement s, include a field of that type in place of the fixed array, and then index into that with pointer offsets.
Thats basically what I was considering using it for, unsafe code. The
thought came up most recently when I was faced with the possible need to
write an ISO-9660 image reader class, and the thought came to me to use
unsafe code to map to the headers for reasons explainable only by having
spent enough time in C that pointers just wont' stop dancing around in my
head. That basically illustrates my point, I've thought about the need for
inline arrays in structures a number of times, and in the vast majority of
them I realize that they wouldn't be a good way to go even if it was
possible currently, thus a feature I would very rarely use but would always
miss, because I know that eventually I am going to need it for something.
Mattias
-- Mattias Sjögren [MVP] mattias @ mvps.org http://www.msjogren.net/dotnet/ Please reply only to the newsgroup.
Daniel,
It's been a while since we did stackalloc, but IIRC, we only allowed it as
an initialization because we wanted to limit the impact that it would have
on the language.
To answer your other question about when we'll be talking about other
features, we're working on a merged version of the language spec (new
features + old features), and we're also working on a "what's new in C#"
spec.
Both should show up on the C# dev center on MSDN. The second one should (and
I don't own it....) be up there in the next week or so.
--
Eric Gunnerson
Visit the C# product team at http://www.csharp.net
Eric's blog is at http://blogs.gotdotnet.com/ericgu/
This posting is provided "AS IS" with no warranties, and confers no rights.
"Daniel O'Connell" <onyxkirx@--NOSPAM--comcast.net> wrote in message
news:%2******** ********@TK2MSF TNGP09.phx.gbl. .. Two questions here:
1. Is there any particular reason why when using stackalloc, the code byte *buffer = stackalloc byte[50]; works, but code like byte *buffer; buffer = stackalloc byte[50]; is considered incorrect syntax? Was this an
oversight, a stylistic design, or is there a technical reason it won't work?
2. I was reading an older(circa 2000) question[1] posted to one of these groups in which Eric Gunnerson mentions that the C# team was still talking about a way to declare inlined arrays of base types in structures, basically: struct myStruct { int[5] fiveArrays; //5 ints all in a row in memory, obviously would
need better syntax } out of my own curiosity, has anything about this come up recently? Is the team still considering it? Is something perhaps coming up(or is there something there in 1.1 I've not managed to find?).
1. http://tinyurl.com/vi0s
"Eric Gunnerson [MS]" <er****@online. microsoft.com> wrote in message
news:OI******** ******@tk2msftn gp13.phx.gbl... Daniel,
It's been a while since we did stackalloc, but IIRC, we only allowed it as an initialization because we wanted to limit the impact that it would have on the language.
Interesting. stackalloc was about the only keyword I had any trouble with.
When I first came across it and started playing with it, I managed to miss
the requirement that it only be used in an initalization. So, I'm sitting
there wondering why exactly visual studio and the spec mentions this
keyword, but the compiler won't accept it. It took a bit to figure out.
To answer your other question about when we'll be talking about other features, we're working on a merged version of the language spec (new features + old features), and we're also working on a "what's new in C#" spec.
Both should show up on the C# dev center on MSDN. The second one should
(and I don't own it....) be up there in the next week or so.
I'll keep my eyes open, thanks for the info. -- Eric Gunnerson
Visit the C# product team at http://www.csharp.net Eric's blog is at http://blogs.gotdotnet.com/ericgu/
This posting is provided "AS IS" with no warranties, and confers no
rights. "Daniel O'Connell" <onyxkirx@--NOSPAM--comcast.net> wrote in message news:%2******** ********@TK2MSF TNGP09.phx.gbl. .. Two questions here:
1. Is there any particular reason why when using stackalloc, the code
byte *buffer = stackalloc byte[50]; works, but code like byte *buffer; buffer
= stackalloc byte[50]; is considered incorrect syntax? Was this an oversight, a stylistic design, or is there a technical reason it won't work?
2. I was reading an older(circa 2000) question[1] posted to one of these groups in which Eric Gunnerson mentions that the C# team was still
talking about a way to declare inlined arrays of base types in structures, basically: struct myStruct { int[5] fiveArrays; //5 ints all in a row in memory, obviously would need better syntax } out of my own curiosity, has anything about this come up recently? Is
the team still considering it? Is something perhaps coming up(or is there something there in 1.1 I've not managed to find?).
1. http://tinyurl.com/vi0s
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Spammay Blockay |
last post by:
I've been tasked with doing technical interviews at my company,
and I have generally ask a range of OO, Java, and "good programming
technique" concepts.
However, one of my favorite exercises I give interviewees seems
to trip them up all the time, and I wonder if I'm being too much
of a hardass... it seems easy enough to ME, but these guys, when
I get them up to the whiteboard, seem to get really confused.
The exercise is this:
|
by: Ross Micheals |
last post by:
All
I have some general .NET questions that I'm looking for some help with. Some of these questions (like the first) are ones that I've seen various conflicting information on, or questions that I'm not sure are specific anomolies that I'm having, or if they are specific known issues I'm facing.
1. In VB.NET, are arrays stored on the stack or the heap? Why must arrays of value types be boxed
in order for them to be (effectively) passed by...
|
by: S Austin |
last post by:
Discovered recently (duh) that putting inline code in .h files (e.g.
in class definitions) is not a good idea when building DLLs and the
applications that use those DLLs. The reason being, of course, is
that the application gets its own copy of that code when it compiles
and won't call the code in the DLL. Each compiled unit in the DLL also
ends up with its own copy of the never-called code.
Assuming the same build process for the DLL...
|
by: prashna |
last post by:
Hi Guru's,
Here are my questions...
1)Why does c allows an extra "," in array intialiser?Is there any
advantage of this?
ex: int arr={1,2,3,4,5,};
^^Compiler does not give error for this!
2)How to determine the size of the array which is passes as a
|
by: Rano |
last post by:
/*
Hello,
I've got some troubles with a stupid program...
In fact, I just start with the C language and sometime
I don't understand how I really have to use malloc.
I've readden the FAQ http://www.eskimo.com/~scs/C-faq/faq.html
but it doesn't seem to answer my questions...
So, I've made an example behind, with some included questions...
| |
by: Victor S. |
last post by:
1. What is System.Windows.Forms.VisualStyles.TextMetricsCharacterSet
good for?
2. Are the Indic scripts supported?
Are all supported scripts fully supported? (for printing and fine
measuring)
Is the printing done by GDI++ without using Unicribe?
3. Is the Text.Encoder/Decoder provided by the OS or by the Framework?
|
by: fctk |
last post by:
hello,
i have some questions.
1) do constant expressions include string literals? for example, is
"hello, world" a constant expression?
2) int i = 0; is the equal sign the assignment operator or is it only a
symbol? (i think the last one is correct)
|
by: efrat |
last post by:
Hello,
I'm planning to use Python in order to teach a DSA (data structures
and algorithms) course in an academic institute. If you could help out
with the following questions, I'd sure appreciate it:
1. What exactly is a Python list? If one writes a, then is the
complexity Theta(n)? If this is O(1), then why was the name "list"
chosen? If this is indeed Theta(n), then what alternative should be
used? (array does not seem suited for...
|
by: valentin tihomirov |
last post by:
Typically, you need the stackalloc when using win32 platform fucntions,
which tell you the amount of memory required for the output structure in the
first call, like GetJob does. The weired thing is that this works:
byte* p = stackalloc byte;
JOB_INFO_2* ji2 = (JOB_INFO_2*) p;
But the immediate casting does not:
JOB_INFO_2* ji2 = (JOB_INFO_2*) stackalloc byte;
It throws a lot of compilation messages. Peahaps, it is a compiler bug.
|
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...
|
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...
| |
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...
|
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...
|
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();...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |