flamingo_pinyata@sopuli.xyz to Programmer Humor@programming.dev · 2 days agoYou can pry pattern matching from my cold dead handssopuli.xyzimagemessage-square218fedilinkarrow-up1506arrow-down118
arrow-up1488arrow-down1imageYou can pry pattern matching from my cold dead handssopuli.xyzflamingo_pinyata@sopuli.xyz to Programmer Humor@programming.dev · 2 days agomessage-square218fedilink
minus-squarecryoistalline@lemmy.mllinkfedilinkarrow-up4·18 hours 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.
minus-squarefruitcantfly@programming.devlinkfedilinkarrow-up4·16 hours agoC++ is even worse, due to templates and the so-called most vexing parse. Initializing with {} mitigated the latter somewhat, but came with its own set of woes
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.
C++ is even worse, due to templates and the so-called most vexing parse. Initializing with
{}mitigated the latter somewhat, but came with its own set of woes