Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
10/28/08 14:25
Read: times


 
#159418 - one-char index isn't a problem
Responding to: ???'s previous message
I regularly use my one-letter x,y or i,j or whatever.

In a huge number of cases, the intention of an index variable is obvious from it's usage:
bitmap[x][y] = value;
row[i] = my_text;
event_queue[i] = modem_event;
...

There is no problem using one-character variables. But only if the code is written in a way where it is obvious that the variable is just an index to scan through a known array or similar.

And more importantly: hard-coded numbers are so very, very dangerous. It is impossible to understand what the comparison does. And it is easy to forget to update all hard-coded constants when modifying the code. And a search may find many collisions since a digit 7 can mean so many things at different places in a big code file, while LAST_SCANLINE should only mean one thing.

List of 70 messages in thread
TopicAuthorDate
C vs Pascal            01/01/70 00:00      
   A long time ago, in a Galaxy far, far away...            01/01/70 00:00      
      Choice ?            01/01/70 00:00      
   Chalk and Cheese            01/01/70 00:00      
      A bit too simplistic analysis            01/01/70 00:00      
         Bondage and discipline            01/01/70 00:00      
            Yes, you can            01/01/70 00:00      
               ?            01/01/70 00:00      
                  Thinking hard about writing code is essential            01/01/70 00:00      
                  blame users, not tools            01/01/70 00:00      
                     Real Programmers            01/01/70 00:00      
                        It\'s back to planning and documentation again            01/01/70 00:00      
         readibility            01/01/70 00:00      
            I have and do            01/01/70 00:00      
               I fully agree            01/01/70 00:00      
               C *is* cryptic by design            01/01/70 00:00      
                  You say cryptic, I say terse            01/01/70 00:00      
                     and what is the purpose...            01/01/70 00:00      
                        terseness/ clatity            01/01/70 00:00      
                           any language depends on naming            01/01/70 00:00      
                              i do not            01/01/70 00:00      
                                 Why not, if appropriate?            01/01/70 00:00      
                                    one-char index isn't a problem            01/01/70 00:00      
                           never say never to have a multiline C construct            01/01/70 00:00      
                              multi-line conditional            01/01/70 00:00      
                  still just symbols            01/01/70 00:00      
                  No one says you have to use every short cut in C            01/01/70 00:00      
                     it's not the shortcuts...            01/01/70 00:00      
                        whatever it is            01/01/70 00:00      
                           Just a minute ...            01/01/70 00:00      
                              C can thrill you            01/01/70 00:00      
                  Not the point            01/01/70 00:00      
            free choice            01/01/70 00:00      
               commercial?            01/01/70 00:00      
                  yes, commercial            01/01/70 00:00      
                     I did never question...            01/01/70 00:00      
                        choices are good            01/01/70 00:00      
                           yeah, yeah            01/01/70 00:00      
                              ADD 1 TO COBOL            01/01/70 00:00      
                                 On Languages            01/01/70 00:00      
                                    braces            01/01/70 00:00      
                                       I like the literal BEGIN and END much better!            01/01/70 00:00      
                                          Perhaps            01/01/70 00:00      
                                             That\'s not what I meant ...            01/01/70 00:00      
                                                There I disagree            01/01/70 00:00      
                                                   words vs symbols - maybe solution for Richard            01/01/70 00:00      
                                                   Humans have to understand it, too            01/01/70 00:00      
                                                Games are for kidz            01/01/70 00:00      
                                                   headstart            01/01/70 00:00      
                                                      still comparing grass straws            01/01/70 00:00      
                                                         you said it            01/01/70 00:00      
                                                            but you did not get it            01/01/70 00:00      
                                                               good joke            01/01/70 00:00      
                                                                  yet more extrapolations/flame baits            01/01/70 00:00      
                                          BEGIN and END            01/01/70 00:00      
                                             No .. I probably should have listened to Mom ...            01/01/70 00:00      
                                    Pascal            01/01/70 00:00      
      More than a language            01/01/70 00:00      
         some of this is language independent            01/01/70 00:00      
            I love standards            01/01/70 00:00      
               Igor recognizes this...            01/01/70 00:00      
         Answers applicable to Turbo51            01/01/70 00:00      
            don't call it IDE...            01/01/70 00:00      
               IDE vs editor            01/01/70 00:00      
                  DIY or gdb or?            01/01/70 00:00      
                     GDB?            01/01/70 00:00      
                     8051 IDE            01/01/70 00:00      
                        this one?            01/01/70 00:00      
   On T51            01/01/70 00:00      
      Some cooments            01/01/70 00:00      

Back to Subject List