Path: csiph.com!usenet.pasdenom.info!dedibox.gegeweb.org!gegeweb.eu!nntpfeed.proxad.net!proxad.net!feeder1-2.proxad.net!usenet-fr.net!nerim.net!novso.com!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.006 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'value,': 0.04; 'subject:Python': 0.06; 'conventions': 0.07; 'pointers': 0.09; 'subject:language': 0.09; 'sure,': 0.09; 'cc:addr:python-list': 0.11; 'frame,': 0.16; 'heap': 0.16; 'integer,': 0.16; 'lasts': 0.16; 'malloc': 0.16; 'subject:programming': 0.16; 'wrote:': 0.18; 'do.': 0.18; 'obviously': 0.18; 'wed,': 0.18; 'stack': 0.19; 'cc:addr:python.org': 0.22; "aren't": 0.24; 'pointer': 0.24; 'cc:2**0': 0.24; 'subject:/': 0.26; 'primary': 0.26; 'defined': 0.27; 'header:In-Reply-To:1': 0.27; 'chris': 0.29; 'dec': 0.30; 'message-id:@mail.gmail.com': 0.30; 'program,': 0.31; 'usually': 0.31; 'correctly.': 0.31; 'figure': 0.32; 'stuff': 0.32; 'could': 0.34; 'anywhere': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'c++': 0.36; 'wrong': 0.37; 'sometimes': 0.38; 'pm,': 0.38; 'duration': 0.60; 'simple': 0.61; 'term': 0.63; 'kind': 0.63; 'more': 0.64; 'to:addr:gmail.com': 0.65; 'yes': 0.68; 'lot,': 0.93; 'tied': 0.93; '2013': 0.98 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=db9eADd/1+PG3b2dXAvAPvnh5KPc64FkSPgiaff2S0M=; b=p+vvyNgKHaE/tVIcI8V56UW7boIahPw8fvDycvbFEGhLMHpEbWa6rO4dwsWrEj290I RNK0vmtuosY4dFiSfluTT4c18Fsr+V1DhKRqs8lKgv+KFT/Vud94hch7K5xoW6hxAWz9 GtVyJq0+T1eEaLBRU6Z122UdWnBmkZF1eb0Dgyis+0fN6PEBw6rqId8G9H7tIySK3HyO E+Cd4r1LXhC3MCnKLMudE+2d5AZOHEqaFAmZF1cSb6C1UU2xAEdT8zmkvKXzj/kbeZJ+ ODQhgEzuIJvD4Qm0lrY+rjSdYHx/nat9mOm9WvT39vFecNx2yAAKtV7BKaGBqzLSYf9Y 037g== X-Received: by 10.229.13.133 with SMTP id c5mr48875473qca.22.1387336360300; Tue, 17 Dec 2013 19:12:40 -0800 (PST) MIME-Version: 1.0 In-Reply-To: References: <20131212213602.806ef8fd2626ca6f34bc83d6@gmx.net> <20131216213225.2006b30246e3a08ee241a191@gmx.net> <20131217165144.39bf9ba1cd4e4f27a96893ca@gmx.net> From: Devin Jeanpierre Date: Tue, 17 Dec 2013 19:12:00 -0800 Subject: Re: Experiences/guidance on teaching Python as a first programming language To: Chris Angelico Content-Type: text/plain; charset=UTF-8 Cc: "comp.lang.python" X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 28 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1387336362 news.xs4all.nl 2901 [2001:888:2000:d::a6]:47618 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:62257 On Tue, Dec 17, 2013 at 7:01 PM, Chris Angelico wrote: > On Wed, Dec 18, 2013 at 1:33 PM, Devin Jeanpierre > wrote: >> Yes you do. Lifetimes are hard, because you need to malloc a lot, and >> there is no defined lifetime for pointers -- they could last for just >> the lifetime of a stack frame, or until the end of the program, or >> anywhere in-between, and it's impossible to know for sure, and if you >> get it wrong your program crashes. So there's all these conventions >> you have to come up with like "borrowing" and "owning", but they >> aren't compiler-enforced, so you still have to figure it out, and you >> will get it wrong. Successors like C++ mitigate these issues with >> destructors (allowing heap-allocated stuff to be tied to the lifetime >> of a stack), and smart pointers and so on. > > Wrong. A pointer is a scalar value, usually some kind of integer, and > its lifetime is the same as any other scalar. The duration of a pointer's validity is far more interesting, and that is why it is the primary meaning of the term "pointer lifetime". Also, it's obviously what I meant. > Heap memory's lifetime > is also very simple: it lasts until freed. Sometimes simple things are hard to use correctly. I only said it was hard, not complicated. -- Devin