[Tutor] 'with foo' was Languages
Jeff Shannon
jeff@ccvcorp.com
Fri, 29 Mar 2002 09:53:26 -0800
> dman <dman@dman.ddts.net> wrote:
>
> On Thu, Mar 28, 2002 at 04:29:09PM -0800, Jeff Shannon wrote:
> | I disagree. The lines following 'with foo' have unqualified names,
> | which look to me like local variables rather than object attributes.
> | When I see 'o.bar', I know I'm accessing an object, and it's not
> | that hard to glance up and see what 'o' has been bound to.
>
> I think this applies equally well to the magic "this" in C++ and Java.
> After spending some time in python where instance members and methods
> are explicitly qualified, I have more trouble following C++/Java that
> relies on the automatic (unqualified) scoping of members. Now my
> C++/Java style is to always use 'this.' (or 'this->' for C++) when
> accessing members.
I totally agree. I haven't done any significant C/C++ since I started using Python (no call for it at work, and I'd much rather use Python for hobby stuff), but when I did use it, the magic "this" was one of the things that always confused me. Since I was far
from expert, I spent a fair amount of time reading others' code, and I had a horrible time trying to figure out what was an object attribute and what was a local variable -- really, the only way to do it is to have *both* the .cpp and the .h file open, and keep
scrolling around in both of them (and this in the days when a 15" monitor was considered average) .... Python's explicit 'self' has saved me endless amounts of grief, in this respect, and I'd hate to see anything that heads Python back in the direction of that
magic "this" ...
> | Matter of taste and previous experience, I suppose.
>
> Agreed.
As a minor reference point (since this thread started on this topic ;) ) my programming experience started with Basic on an Apple //e, at an age of about 12. I then did nothing with programming for 5 or 6 years, took a Fortran/Basic class in college and did
poorly... but, after leaving college, I decided to pick up a book on C and toyed with that for a little while, and had a lot of fun with it. I went a couple of years with no computer access after that, then in the early 90s got my own PC, started up with C again,
then taught myself C++ and looked at Assembler (x86) a bit. As my job has moved more and more into programming, I've been using mostly Basic (some VB, but mostly a proprietary dialect for our Pick/D3 database), a truly horrid proprietary scripting language for
that database (I'd describe it as combining the worst aspects of shell scripting and SQL, but that makes it sound better than it is)... and Python. Needless to say, I try to keep myself working on the projects for which Python is the most useful. :)
Jeff Shannon
Technician/Programmer
Credit International