Path: csiph.com!usenet.pasdenom.info!news.albasani.net!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Gregory Ewing Newsgroups: comp.lang.python Subject: Re: Experiences/guidance on teaching Python as a first programming language Date: Thu, 19 Dec 2013 19:41:00 +1300 Lines: 38 Message-ID: References: <20131212213602.806ef8fd2626ca6f34bc83d6@gmx.net> <20131216213225.2006b30246e3a08ee241a191@gmx.net> <20131217165144.39bf9ba1cd4e4f27a96893ca@gmx.net> <52b0fb4f$0$29973$c3e8da3$5496439d@news.astraweb.com> <52b15b62$0$29973$c3e8da3$5496439d@news.astraweb.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net ZYsR83G+zH8vQ0wmofun1wIN3I8kG90IyyNxIMOqge7nuB4KFP Cancel-Lock: sha1:WdeYp0o4X4zLvmPHdrVKdhRqZmI= User-Agent: Mozilla Thunderbird 1.0.5 (Macintosh/20050711) X-Accept-Language: en-us, en In-Reply-To: Xref: csiph.com comp.lang.python:62379 Dave Angel wrote: > C is a glorified macro assembler. So the -> operator is not analogous > to the dot operator, it's Syntactic sugar: > > p-> a. Is really > (*p).a But it's not above inferring a dereferencing operation when you call a function via a pointer. If f is a pointer to a function, then f(a) is equivalent to (*f)(a) If the compiler can do that for function calls, there's no reason it couldn't do it for member access as well. If I remember rightly, Ada not only does implicit dereferencing like this, it doesn't even have an explicit dereferencing operator! If you want to refer to the whole record pointed to by p, you have to say 'p.all'. BTW, the whole notion of a "pointer to a function" is redundant in C, since you can't do anything with what it points to other than call it. The equivalent concept in Modula, for example, is just called a function type, not a pointer-to- function type. Similarly in most languages that have functions as values. -- Greg