Skip to content

Instantly share code, notes, and snippets.

@zeroeth
Created September 16, 2013 06:55
Show Gist options
  • Select an option

  • Save zeroeth/6577384 to your computer and use it in GitHub Desktop.

Select an option

Save zeroeth/6577384 to your computer and use it in GitHub Desktop.
Looking at ways of creating named parameters in C/C++ that's aesthetically pleasing.
/* TYPE 1 */
Spot left_spot = Spot (/* eye: */ 0, /* position: */ 5, /* width: */ 3, /* color: */ led_strip.Color (5, 0, 0));
/* TYPE 2 */
Spot left_spot = Spot ( /* eye */ 0,
/* position */ 5,
/* width */ 3,
/* color */ led_strip.Color (5, 0, 0));
/* TYPE 3 */
Spot left_spot;
void setup ()
{
left_spot.eye = 0;
left_spot.position = 5;
left_spot.width = 3;
left_spot.color = led_strip.Color ( 5, 0, 0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment