Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #7494

Re: Function declarations ?

From Andre Majorel <cheney@halliburton.com>
Newsgroups comp.lang.python
Subject Re: Function declarations ?
Date 2011-06-12 19:38 +0000
Organization Dirac Angestun Gesept
Message-ID <slrniva5en.8s9.cheney@atc5.vermine.org> (permalink)
References <slrniuv00f.8s9.cheney@atc5.vermine.org> <e7913881-3028-4370-b4f5-7a7b17b04be0@h7g2000yqa.googlegroups.com>

Show all headers | View raw


On 2011-06-10, Asen Bozhilov <asen.bozhilov@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 ?

> JavaScript is the perfect example. Hoisted environment allows
> you to use call expression before the physical declaration of
> the function in the source text.

The issue here is not the ability to call a function before its
declaration. It's being able to do so before its definition.

> Hope this helps, why Python use definitions instead of
> declarations.

It's not either/or. Any language has to provide a way to define
functions whether or not it provides a way to declare them.

Anyway, it seems the Python way to declare a function is

  def f ():
    pass

Thanks everyone.

-- 
André Majorel http://www.teaser.fr/~amajorel/
J'ai des droits. Les autres ont des devoirs.

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Function declarations ? Andre Majorel <cheney@halliburton.com> - 2011-06-08 13:58 +0000
  Re: Function declarations ? Calvin Spealman <ironfroggy@gmail.com> - 2011-06-08 10:06 -0400
  Re: Function declarations ? "D'Arcy J.M. Cain" <darcy@druid.net> - 2011-06-08 10:27 -0400
  Re: Function declarations ? Asen Bozhilov <asen.bozhilov@gmail.com> - 2011-06-10 15:46 -0700
    Re: Function declarations ? Andre Majorel <cheney@halliburton.com> - 2011-06-12 19:38 +0000
      Re: Function declarations ? Tim Roberts <timr@probo.com> - 2011-06-12 21:27 -0700
        Re: Function declarations ? Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2011-06-14 14:03 +1200
      Re: Function declarations ? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-06-13 14:58 +0000
        Re: Function declarations ? Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2011-06-14 13:18 +1200
      Re: Function declarations ? John Nagle <nagle@animats.com> - 2011-06-13 17:19 -0700

csiph-web