Re: Experiences/guidance on teaching Python as a first programming language

Dave Angel davea at davea.name
Wed Dec 18 07:53:23 EST 2013


On 18 Dec 2013 08:22:58 GMT, Steven D'Aprano <steve at pearwood.info> 
wrote:
> On Wed, 18 Dec 2013 13:11:58 +1100, Chris Angelico wrote:
> > The one differentiation that I don't like is between the . and ->
> > operators. The distinction feels like syntactic salt. There's no 
context
> > when both are valid, save in C++ where you can create a 
"pointer-like
> > object" that implements the -> operator (and has the . operator 
for its
> > own members).

Funny you should say that in the middle of a discussion about 
lifetime.  In C, when you do the -> thing, you're now in a different 
struct with a potentially different lifetime.  If p is a local,  with 
auto lifetime,  then so is p.x

So, although the two are mutually exclusive,  there's valuable 
information hidden in the required choice.

-- 
DaveA




More information about the Python-list mailing list