Hacker News new | past | comments | ask | show | jobs | submit login

It depends on the language's semantics. Sometimes (as in Python), `target.method(a, b)` really is two separate operations, `target.method` (which returns a bound function) and then `<thing>(a, b)` which applies arguments to the result.

Even then, it's still not a prefix operation. It's postfix.




Whew. (Wipes sweat off brow).

Things like this are mentioned, in some detail, in the O'Reilly book Python in a Nutshell, IIRC, in the first edition, which is what I have.

Couldn't quite wrap my head around all the material in that chapter, TBH.

But I still like to read about such stuff, and I do understand bits and pieces of it.


In Python, the "." in "target . method" is an infix operator.

Note that the "(" in (a, b) is also an operator. (There is some special parsing because otherwise you could do things like args = (1, 2, b=3); target.method args.)

As to whether <thing from target.method><thing from (a, b)> is postfix, I'm not sure how you get there. Yes, there's an implicit funcall at the end, but there's something similar with (+ a b) or ((. target method) (arglist a b)) and we wouldn't call them postfix.


You're right. Function application is essentially an infix `(` operator. Not sure how I got that wrong.




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: