minus-squarecryoistalline@lemmy.mltoProgrammer Humor@programming.dev•You can pry pattern matching from my cold dead handslinkfedilinkarrow-up4·3 days agotypes in C are pretty weird int *a can be read as *a is a int since dereferencing is a operator on pointers, a is a pointer to int int *a, b is read as *a and b are int so a is a pointer to int and b is a int bool getofmylawn(Lawn lawn) getoffmylawn(Lawn lawn) is a bool since calling is done on functions, getoffmylawn is a function that takes a Lawn and returns a bool And then you have function pointers bool (*foo(int a))(float b) (*foo(int a))(float b) is a bool *foo(int a) is a function from float to bool foo(int a) is a function pointer from float to bool foo is a function that takes a int and returns a function pointer from float to bool really weird in my opinion. linkfedilink
types in C are pretty weird
int *acan be read as*ais a intais a pointer tointint *a, bis read as*aandbareintais a pointer tointandbis aintbool getofmylawn(Lawn lawn)getoffmylawn(Lawn lawn)is aboolgetoffmylawnis a function that takes aLawnand returns aboolAnd then you have function pointers
bool (*foo(int a))(float b)(*foo(int a))(float b)is abool*foo(int a)is a function fromfloattoboolfoo(int a)is a function pointer fromfloattoboolfoois a function that takes aintand returns a function pointer fromfloattoboolreally weird in my opinion.