[ prog / sol / mona ]

prog


Lexical Scoping == Tyranny

28 2020-11-03 19:19

>>27 thats not "unreadable", its code for public consumption.
I can write code with shorter variables and more macros.
Indentation also not used at all. Compare this with https://raw.githubusercontent.com/FrozenVoid/C-techniques/master/scope.c

#include "Util/void.h"
int g=4,l=50;
#define prscope(s) print(s,g,l)
void f(char*s){prscope(s);}
#define ex(s) ({prscope(s);})
void of(char*s){prscope(s);}
void f2(char* scope){int g=2000,l=6000; 
void f3(char*s){prscope(s);};f3(scope);//2000,6000
atype fptr=of;fptr("\nGlobals again:");
ex("\nContext scope again:");}
int main(int argc,char**argv){
int g=5,l=100;
ex("\nContext scope:");
with(int g=1,l=2,prscope("\nLocal scope:"));
prscope("\nOuter scope:");
f("\nGlobal scope:");f2("\nDynamic scope:");
do{int g=-1,l=-400;prscope("\ndo loop context:");}while(0);
//inline block context {}
{int g=-44,l=-233;prscope("\nBlock scope:");
{int g=-20000,l=5055;prscope("\nNext layer of block scope:");
{int g=-201,l=654654;prscope("\nNesting of block scope:");}
prscope("\nNext layer of block scope returns:");}
prscope("\nBlock scope returns:");}
prscope("\nback to main context:");}
48


VIP:

do not edit these