c++11 - Can I create a new syntax in C++? -
i quite fond of python generator expression , (ab)use lot in python. (up no good) working on implementing generator expression on c++ 11, using macros embedded in macros, lambdas , more obscure things. aim copy abilities of operator close possible. there implementations already, lack multi-variable support.
python complex syntax looks like
generator = i*j i,j in zip(arr1,arr2) if i>0 , j>0 # python
this line produces functor returns on every successfull call multiplication of repective values 2 arrays. , in realization syntax looks
auto generator = brf_genexpr(i*j,(i,j),zip(arr1, arr2),i>0 && j>0); //c++11
my question is: know way, exotic, rid of lots of commas , allow me write
auto generator = brf_genexpr(i*j i,j in zip(arr1,arr2) if (i>0 && j>0));
i understand can write preprocessor script change syntax me, love in-code solution.
updates:
- my question call syntax, implementation working already.
no, impossible use language keywords (for
, if
) in new ways.
if you're willing use different tokens (such 'genfor,
genif`), possible.
Comments
Post a Comment