Static arrays and ellipsis

This is a discussion on Static arrays and ellipsis within the C Programming forums, part of the General Programming Boards category; well since C99, the concept of ellipsis has been introduced in variable arguments for macros and since has been extended ...

  1. #1
    Banned
    Join Date
    May 2009
    Posts
    37

    Static arrays and ellipsis

    well since C99, the concept of ellipsis has been introduced in variable arguments for macros and since has been extended to templates...

    what i've been wondering is why it has not been extended for declaring static arrays to address the array from the highest place to the lower....

    ex:

    Code:
    type array[10] = {undefined, undefined, undefined, undefined, undefined, undefined, 1, 2, 3, 4};
    to:
    Code:
    type array[10] = {..., 1, 2, 3, 4}

    OR:

    Code:
    type array[10] = {0, 0, undefined, undefined, undefined, undefined, 1, 2, 3, 4};
    to:
    Code:
    type array[10] = {0, 0, ..., 1, 2, 3, 4};

    i believe this comes handy when instead of typing "10" for the number of elements, you have it statically predefined somewhere else in the library...
    Last edited by renzokuken01; 12-29-2010 at 11:52 PM.

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    Ellipses have been in C since well before 1999 and templates have been in C since exactly never.

    And they did it for you anyway:
    Code:
    type array[SIZE] = {[SIZE-4]=1, 2, 3, 4};
    (EDIT: Oh, if you mean ellipses for macros, then I think that is new in 99 yes. I still have no idea where you're headed with templates, though.)
    Last edited by tabstop; 12-30-2010 at 12:07 AM.

  3. #3
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    I can't possibly think of a use for initializing only the end of an array.


    Quzah.
    Hope is the first step on the road to disappointment.

  4. #4
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    I'm pretty sure the "real" use case is for things like sparse matrices, since you still get the auto-fill-with-zeroes feature.

  5. #5
    Banned
    Join Date
    May 2009
    Posts
    37
    (EDIT: Oh, if you mean ellipses for macros, then I think that is new in 99 yes. I still have no idea where you're headed with templates, though.)
    i was wrong about the templates... i glossed over the wikipedia and thought it was ALSO talking about plain old C (which i just took to be true, as there may be variants of C like that...) even though i've never seen any templates for C.

  6. #6
    Banned
    Join Date
    May 2009
    Posts
    37
    Quote Originally Posted by quzah View Post
    I can't possibly think of a use for initializing only the end of an array.

    Quzah.
    alright.. well, what do you think of only initializing the start of the arrays??

  7. #7
    Banned
    Join Date
    May 2009
    Posts
    37
    look, i know a lot of you think in very "concrete" terms... if there are NO PREVIOUS EXAMPLE, then it CAN'T BE. you think in terms of that... instead of very concise solutions with huge implications. you think of very specific programs... sort of like your IT course lecturer telling you ok, write me this program and that does specifically this and that...

    ...and my babblings about standard this and standard THAT are just philosophical arguments meant to distract you or i' so thoroughly lost that i'm trying to get those other people lost too...

    things that i bring up are no more than little tidbits that i can afford to throw away (without any disadvantage to me) in hopes that some bloke will pass that revision to the next amendment of C.

  8. #8
    Banned
    Join Date
    May 2009
    Posts
    37
    alright... i guess i should be generous this christmas and maybe give away something for free...
    Code:
    it was just a preview and i've given you enough time to see it. now nobody can claim they found the source code free online
    Last edited by renzokuken01; 12-30-2010 at 07:55 PM.

  9. #9
    Banned
    Join Date
    May 2009
    Posts
    37
    i swear to god... if anybody uses this code for any of their projects, i will hunt you down.

    and don't even think of publishing as everybody knows whose work this is
    Last edited by renzokuken01; 12-30-2010 at 06:54 PM.

  10. #10
    Banned
    Join Date
    May 2009
    Posts
    37
    my bad, too you need these 2 to make it work:

    new_inst_strm_stack.def:
    Code:
    /*  for the total memory alloced by stacks, as to what's most optimal is up to the client */
    #ifndef INST_STRM_RESIZE_BUFFER
    #define INST_STRM_RESIZE_BUFFER                       (400)
    #endif
    
    #ifndef INST_STRM_START_BUFFER
    #define INST_STRM_START_BUFFER                        INST_STRM_RESIZE_BUFFER
    #endif
    
    
    
    #ifndef INST_STRM_PRAC_LIMIT
    #define INST_STRM_PRAC_LIMIT                             (1000)
    #endif
    
    
    
    
    #ifndef INST_STRM_LEAVE_MEM_BUFFER
    #define INST_STRM_LEAVE_MEM_BUFFER                (200)
    #endif
    
    
    
    
    
    #ifndef INST_STRM_STACK_ID
          #error "please specify id number"
    #endif
    
    
    #ifdef INST_STRM_NUM_STACK
          #if INST_STRM_STACK_ID >= INST_STRM_NUM_STACK
                #error "stack id exceeds id bounds"
          #endif
    #endif

    new_inst_strm_stack-break.def:
    Code:
    #undef INST_STRM_STACK_ID

  11. #11
    Banned
    Join Date
    May 2009
    Posts
    37
    and don't think this is even a 1/10th of the entirety of my project.

  12. #12
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Quote Originally Posted by renzokuken01 View Post
    alright.. well, what do you think of only initializing the start of the arrays??
    You already can just initialize the start of an array. It's been in the standard forever. Anything you don't initialize is set to zero.
    Code:
    int foo[5] = { 1, 2 }; /* 0, 0, 0 are the last three */

    Quzah.
    Hope is the first step on the road to disappointment.

  13. #13
    Banned ಠ_ಠ's Avatar
    Join Date
    Mar 2009
    Posts
    687
    Quote Originally Posted by renzokuken01 View Post
    i swear to god... if anybody uses this code for any of their projects, i will hunt you down.

    and don't even think of publishing as everybody knows whose work this is
    lol'd
    ╔╗╔══╦╗
    ║║║╔╗║║
    ║╚╣╚╝║╚╗
    ╚═╩══╩═╝

  14. #14
    Banned
    Join Date
    May 2009
    Posts
    37
    Quote Originally Posted by quzah View Post
    You already can just initialize the start of an array. It's been in the standard forever. Anything you don't initialize is set to zero.
    Code:
    int foo[5] = { 1, 2 }; /* 0, 0, 0 are the last three */

    Quzah.
    EXACTLY!!! omfg you, mean, you didn't see this coming?? alright, i'll lay down to you simply so you understand me in detail.

    well from my example above, you can clearly see that i traverse the arrays from highest place to the lowest... and the reason for that may be a variety of things... for my case it's because how CPU flag registers work in CISC... so it's very easy to see why it can be VERY advantageous to address the last elements.... in that manner, initializing the start of a static array is absolutely no different from initializing the last ones.

  15. #15
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    Quote Originally Posted by renzokuken01 View Post
    EXACTLY!!! omfg you, mean, you didn't see this coming?? alright, i'll lay down to you simply so you understand me in detail.

    well from my example above, you can clearly see that i traverse the arrays from highest place to the lowest... and the reason for that may be a variety of things... for my case it's because how CPU flag registers work in CISC... so it's very easy to see why it can be VERY advantageous to address the last elements.... in that manner, initializing the start of a static array is absolutely no different from initializing the last ones.
    So, great. What you want is also already in the standard. And?

    (EDIT: Well, true, the exact syntax you're looking for isn't supported. You have to use the syntax the committee set up. And also, I suppose we should be honored that you think any of us are on the committee, or even know anybody who is on the committee. But I would be very surprised if anyone here is.)
    Last edited by tabstop; 12-30-2010 at 08:02 PM.

Page 1 of 2 12 LastLast
Popular pages Recent additions subscribe to a feed

Tags for this Thread


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21