Skip to content

Instantly share code, notes, and snippets.

@rismay
Created January 25, 2014 20:13
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rismay/8622825 to your computer and use it in GitHub Desktop.
Save rismay/8622825 to your computer and use it in GitHub Desktop.
Lazy Instantiation as a C MACRO
//You should pick one style to use consistantly in your project
//Lazy Intantiation as a C Macro clearly explaining the concept
#define WSM_LAZY(variable, assignment) (variable = variable ?: assignment)
//Lazy Intantiation as a C Macro clearly explaining the language syntax used
#define WSM_TERNARY(variable, assignment) (variable = variable ?: assignment)
//Lazy Intantiation as a semi-operator w/class prefix
#define WSM_$(variable, assignment) (variable = variable ?: assignment)
//Lazy Intantiation as a C Macro clearly explaining the concept and no class prefix
#define _LAZY(variable, assignment) (variable = variable ?: assignment)
//Lazy Intantiation as a semi-operator and no class prefix (very wierd but works)
#define _$(variable, assignment) (variable = variable ?: assignment)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment