<p dir="ltr"><br>
On 13 May 2013 08:40, "Chris Angelico" <<a href="mailto:rosuav@gmail.com">rosuav@gmail.com</a>> wrote:<br>
><br>
> On Mon, May 13, 2013 at 4:32 PM, Fábio Santos <<a href="mailto:fabiosantosart@gmail.com">fabiosantosart@gmail.com</a>> wrote:<br>
> ><br>
> > On 13 May 2013 00:22, "Greg Ewing" <<a href="mailto:greg.ewing@canterbury.ac.nz">greg.ewing@canterbury.ac.nz</a>> wrote:<br>
> >> The same argument can be applied to:<br>
> >><br>
> >>    foo = Foo()<br>
> >>    foo.do_something()<br>
> >>    foo.enable() # should have done this first<br>
> >><br>
> >> You're passing an invalid input to Foo.do_something,<br>
> >> namely a Foo that hasn't been enabled yet.<br>
> ><br>
> > I don't think you can really count that as invalid input in OOP terms. After<br>
> > all in most languages `self` / `this` / whatever is not an argument to every<br>
> > method.<br>
><br>
> Yes, it is; it's just often implicit. C++ lets you poke around with<br>
> the internals, and it's pretty clear that 'this' is an argument. (See<br>
> for instance what happens with the gcc 'format' attribute - I can't<br>
> find a convenient docs page, but it's been mentioned on SO [1] and can<br>
> be easily verified.) EMCAScript lets you call any function with any<br>
> 'this' by using the .call() or .apply() methods - which, in my<br>
> extremely not-humble opinionated opinion, is bad design (closures work<br>
> implicitly, but the 'this' pointer doesn't??). Python turns an<br>
> attribute lookup on an instance into an attribute lookup on the class<br>
> plus a currying. One way or another, the bit-before-the-dot is an<br>
> argument to the function.<br>
><br>
> [1] <a href="http://stackoverflow.com/questions/11621043/how-should-i-properly-use-attribute-format-printf-x-y-inside-a-class">http://stackoverflow.com/questions/11621043/how-should-i-properly-use-attribute-format-printf-x-y-inside-a-class</a><br>

><br>
> ChrisA<br>
> --<br>
> <a href="http://mail.python.org/mailman/listinfo/python-list">http://mail.python.org/mailman/listinfo/python-list</a></p>
<p dir="ltr">I know ECMAScript does that. It would be nice to be able to pass an instance method as a callback argument without using `.bind(theInstance)`.</p>
<p dir="ltr">At any rate, exposed or not, that is all still internals. Exposing the ability to set the ` this ` as an argument is, I think, a functional feature (map(str.strip, file) is a good example)</p>
<p dir="ltr">That said, I didn't know c++ did that, but it makes sense with what I read somewhere about c++ starting out as a transcompiler-to-c-based language.</p>