Re:Open-sourcing MonkeyType – Let your Python code type-hint...
by joshuamorton on Friday December 22, 2017 @12:43AM
(#15985498)
Sure, but at that point you've just reimplemented python in macros ;)
The other thing to note is that
sorted([(k.weight, k.name) for k in somelist], reverse=True)
is essentially already typechecked: def biggest_ks(ks: K):
return sorted([(k.weight, k.name) for k in ks], reverse=True)
The above code now has all the same type guarantees as your c++, actually maybe more since the macros you use are going to be...uhhh, mysterious.
Re:Open-sourcing MonkeyType – Let your Python code type-hint...
by nickelbox on Friday December 22, 2017 @05:12PM
(#15991336)
The macro would only be used to generate k for convenience. It could be all implemented in straight, macro-less C++98 in O(minutes).
My point was just that you can implement almost whatever you want (even without macros, they'll just expand the design space).
Re:Open-sourcing MonkeyType – Let your Python code type-hint...
by joshuamorton on Friday December 22, 2017 @05:18PM
(#15991378)
I don't see how you could implement the (k.attr).for_(k) part. That's essentially an assignment, a macro could maybe convert it to a lambda, but I don't see how it would be done macro-free.
sorted( (k.weight, k.name).for_(k).in(somelist), reverse=true));
You would never be able to get that past code review, however.