[Gambas-user] A fine afternoon for a good rant

Cedron Dawg cedron at exede.net
Thu Feb 28 21:38:14 CET 2019


Wait a sec, you have unbalanced parentheses.

 *((char **)GB.Array.Get(theReturnedArray, f) = theListEntry;

You see, good parentheses spacing is not only more readable, but it is also "error correcting".  

 *( (char**) GB.Array.Get( theReturnedArray, f ) ) = theListEntry;

Annoyance of mine with C and how it is used.  When I am declaring a variable

char* myTitle  vs  char *myTitle

Were it done more commonely like I do it (the left one), there wouldn't me so much confusion of what it means when you use *myTitle to store a value in the code.

The * is a modifier of the type, that's why it needs to be in cast parenthesis:  (char*) theOtherPointerType

Otherwise it should be (char) *theOtherPointerType, but it doesn't work that way.  The parentheses belong to the cast, so they can be tight.

On the other hand, case like if, for, while statements:

    if (logical<>expression) {
       code starts here    
    }
    
Is ugly and unbalanced.  The parentheses belong to the if statement, and the braces should be balanced.

    if( logical <> expression )
    {
       code starts here    
    }

The extra blank line introduced improves the readability.  Spacing inside the lines improves readability as well.  Both let your eyes focus on the actual meaning without having to "parse" out the clutter.

C is still ugly.  Anybody seen my spare semicolon?  Oh, the compiler told me with 400 error messages.  Snark.


----- Original Message -----


   for( f = 0; f < theFoundCount; f++ )
   {
      theListEntry = GB.NewZeroString(theList[f]);
      *((char **)GB.Array.Get(theReturnedArray, f) = theListEntry;
   }

   GB.ReturnObject( &theReturnArray );

Regards,

-- 
Benoît Minisini


More information about the User mailing list