Re: How to do "Compile time" initialization of record array?
- From: "John Kelsey" <kelseyj@xxxxxxxxxx>
- Date: Fri, 30 Dec 2005 12:55:53 -0600
Jon,
For example, one of my "C" programs has
struct
{
double L;
double M;
double S;
} LengthArray[] = {
{ 1.267004226, 49.988884080, 0.053112191}, // 1
{ 0.511237696, 52.695975300, 0.048692684}, // 2
{ -0.452244460, 56.628428550, 0.044116830}, // 3
This is some statistical data (there are 76 records per array) and I have
Length, Weight, and Circumference arrays.
I typically am targeting some low "horsepower" handheld devices.
Even in C, I could run time initialize my arrays but I didn't for at least a
couple of reasons...
1) Performance, why waste runtime cycles building an array when it could be
pre-built by the compiler
2) Run time building meant that I carried two copies of my data in the
"execution footprint". One copy in code segment and the other copy in the
data segment.
I understand that this really doesn't present a challenge to a modern
device, especially in a desktop environment, it was just a style I have/had.
I don't understand C# the way I do C. Things that used to be important, no
longer seem to matter as much.
I've appreciated all of the responses and I'm certain I'll ask more "old
fashioned" questions as I learn.
Thanks,
John Kelsey
"Jon Skeet [C# MVP]" <skeet@xxxxxxxxx> wrote in message
news:MPG.1e1f8db44156943698cc2b@xxxxxxxxxxxxxxxxxxxxxxx
> John Kelsey <kelseyj@xxxxxxxxxx> wrote:
--snip--
>>
>> I guess it boils down to the difference between
>> int i = 32;
>>
>> and
>> int i;
>> ...
>> i = 32;
>
> Well, in that case there really isn't any difference in the compiled
> code, as far as I'm aware. I know what you mean though :)
>
>> Is this any clearer?
>
> While I see what you mean, there isn't a way of doing it that I know of
> in C#, nor do I suspect it's really a problem. Do you have any
> particular reason for desiring it from an execution point of view? You
> can achieve the same "end goal" (getting an initialised array) in C#
> with quite similar code, so it's only the matter of when it actually
> gets built which is significantly different. Are you worried about
> performance?
>
> --
> Jon Skeet - <skeet@xxxxxxxxx>
> http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
> If replying to the group, please do not mail me too
.
- Follow-Ups:
- Re: How to do "Compile time" initialization of record array?
- From: Dave
- Re: How to do "Compile time" initialization of record array?
- From: Jon Skeet [C# MVP]
- Re: How to do "Compile time" initialization of record array?
- References:
- How to do "Compile time" initialization of record array?
- From: John Kelsey
- Re: How to do "Compile time" initialization of record array?
- From: Dave
- Re: How to do "Compile time" initialization of record array?
- From: John Kelsey
- Re: How to do "Compile time" initialization of record array?
- From: Jon Skeet [C# MVP]
- How to do "Compile time" initialization of record array?
- Prev by Date: RE: Filling a DataSet with an ADO Recordset or Record
- Next by Date: [OT] Re: I LOVE THIS JOB !!!
- Previous by thread: Re: How to do "Compile time" initialization of record array?
- Next by thread: Re: How to do "Compile time" initialization of record array?
- Index(es):
Relevant Pages
|