3 ms·
I'm normally a big fan of python operator overload hacks, but why are we doing `wat / foo` instead of just `wat(foo)` ?
by Retr0id 2y ago
I'm normally a big fan of python operator overload hacks, but why are we doing `wat / foo` instead of just `wat(foo)` ?
- JulianChastain 2y ago`wat(foo)` also works. The author says he implmented the `wat / foo` syntax to allow you to more quickly use wat by avoiding parentheses
- deleted 2y ago[deleted]
- contravariant 2y agoProbably so you can run a big complicated formula in the REPL and easily prepend `wat /` to it to inspect what's going on. Same reason jupyter notebooks allow you to prepend '?' or '??' to inspect a variable (though not expressions, in that respect this syntax is better)
- jawns 2y agoI get the reasoning behind it, but the choice of the division operator is still a little weird. I believe it should be equally possible to overload the bitwise OR operator (|), which, for people used to piping in Unix, is probably more intuitive.
- Tomte 2y agoWrong direction: you‘d „pipe“ wat through the object. Although TiddlyWiki users might feel right at home.
- auscompgeek 2y agoIt could override the reverse bitwise or magic method `__ror__`.
- igrek51 2y agoRight, that would be a wrong pipe direction. Fun fact: It's already possible to do "wat | foo" or "wat << foo" (if you're more familiar with C++ iostream), it has the same effect as "wat / foo"