Function declarations ?

John Nagle nagle at animats.com
Mon Jun 13 20:19:35 EDT 2011


On 6/12/2011 12:38 PM, Andre Majorel wrote:
> On 2011-06-10, Asen Bozhilov<asen.bozhilov at gmail.com>  wrote:
>> Andre Majorel wrote:
>>
>>> Is there a way to keep the definitions of the high-level
>>> functions at the top of the source ? I don't see a way to
>>> declare a function in Python.
>>
>> Languages with variable and function declarations usually use
>> hoisted environment.
>
> Hoisted ? With a pulley and a cable ?

    There are languages with definitions and in which
the compiler looks ahead.  FORTRAN, for example.
Python doesn't work that way.  Nor do C and the
languages derived from it, because the syntax
is context-dependent.  (In C++, "A b;" is ambiguous
until after the declaration of A. In
Pascal-derived languages, you write "var b: A;",
which is parseable before you know what A is.
So declarations don't have to be in dependency order.)

    None of this is relevant to Python, but that's
what "hoisted" means in this context..

				John Nagle





More information about the Python-list mailing list