From: Chris Rebert on 11 May 2010 15:25 On Tue, May 11, 2010 at 11:13 AM, Terry Reedy <tjreedy(a)udel.edu> wrote: > On 5/11/2010 7:11 AM, Lawrence D'Oliveiro wrote: >> In message<7xvdavd4bq.fsf(a)ruckus.brouhaha.com>, Paul Rubin wrote: >> >>> Python is a pragmatic language from an imperative tradition ... >> >> I thought the opposite of âfunctionalâ was âproceduralâ, not âimperativeâ. >> The opposite to the latter is âdeclarativeâ. But (nearly) all procedural >> languages also have declarative constructs, not just imperative ones >> (certainly Python does). > > Python has only two: 'global' and now 'nonlocal'. > There are also two meta-declarations: the coding cookie (which would/will go > away in an entirely unicode world) and future imports (which are effectively > temporarily gone in 3.x until needed again). > > Newbies sometimes trip over def and class being imperative (executable) > statments rather than declarations. Er, declarative programming has nothing to do with variable declarations. http://en.wikipedia.org/wiki/Declarative_programming Cheers, Chris -- http://blog.rebertia.com
From: Terry Reedy on 11 May 2010 16:00 On 5/11/2010 3:25 PM, Chris Rebert wrote: > On Tue, May 11, 2010 at 11:13 AM, Terry Reedy<tjreedy(a)udel.edu> wrote: >> On 5/11/2010 7:11 AM, Lawrence D'Oliveiro wrote: >>> In message<7xvdavd4bq.fsf(a)ruckus.brouhaha.com>, Paul Rubin wrote: >>> >>>> Python is a pragmatic language from an imperative tradition ... >>> >>> I thought the opposite of âfunctionalâ was âproceduralâ, not âimperativeâ. >>> The opposite to the latter is âdeclarativeâ. But (nearly) all procedural >>> languages also have declarative constructs, not just imperative ones >>> (certainly Python does). >> >> Python has only two: 'global' and now 'nonlocal'. >> There are also two meta-declarations: the coding cookie (which would/will go >> away in an entirely unicode world) and future imports (which are effectively >> temporarily gone in 3.x until needed again). >> >> Newbies sometimes trip over def and class being imperative (executable) >> statments rather than declarations. > > Er, declarative programming has nothing to do with variable declarations. > http://en.wikipedia.org/wiki/Declarative_programming I found it hard to get much from the vague description. I will leave it to Lawrence to list what *he* thinks are 'declarative constructs' in Python.
From: Nobody on 11 May 2010 16:03 On Tue, 11 May 2010 07:36:30 -0700, Paul Rubin wrote: > Offhand I can't tell that imperative and procedural mean something > different. Both basically mean that the programmer specifies a series of > steps for the computer to carry out. Functional languages are mostly > declarative; for example, an expression like > x = 3 > is called an "equation" rather than an "assignment". It declares "x is > equal to 3", rather than directing x to be set to 3. If someplace else in > the program you say "x = 4", that is an error, normally caught by the > compiler, since x cannot be equal to both 3 and 4. In both ML and Haskell, bindings are explicitly scoped, i.e. let x = 3 in ... end (ML) let x = 3 in ... (Haskell) If you bind a variable which is already bound, it introduces a new binding which "overrides" the existing binding. It won't generate an error. The key point is that a variable has a fixed (constant) value at any specific point in the program. The value depends upon which bindings are in scope at that point, and not on the "state" of the variable at a particular point in time. E.g. (Haskell): test y = let x = 3 in let f y = x + y in let x = 5 in f y test 5 8 x has the value 3 at the point that f is defined, so that's the value which is used when f is used.
From: Lie Ryan on 11 May 2010 15:59 On 05/12/10 05:25, Chris Rebert wrote: > On Tue, May 11, 2010 at 11:13 AM, Terry Reedy <tjreedy(a)udel.edu> wrote: >> On 5/11/2010 7:11 AM, Lawrence D'Oliveiro wrote: >>> In message<7xvdavd4bq.fsf(a)ruckus.brouhaha.com>, Paul Rubin wrote: >>> >>>> Python is a pragmatic language from an imperative tradition ... >>> >>> I thought the opposite of “functional” was “procedural”, not “imperative”. >>> The opposite to the latter is “declarative”. But (nearly) all procedural >>> languages also have declarative constructs, not just imperative ones >>> (certainly Python does). >> >> Python has only two: 'global' and now 'nonlocal'. >> There are also two meta-declarations: the coding cookie (which would/will go >> away in an entirely unicode world) and future imports (which are effectively >> temporarily gone in 3.x until needed again). >> >> Newbies sometimes trip over def and class being imperative (executable) >> statments rather than declarations. > > Er, declarative programming has nothing to do with variable declarations. > http://en.wikipedia.org/wiki/Declarative_programming > Variable declarations have everything to do with declarative programming. An imperative way to create a variable is to allocate the memory yourself and instead of "variables" you have just registers and the memory; fortunately all popular imperative languages (wisely) picks up declarative syntax from the declarative paradigm. In Python, the regular def/class is a pseudo-declaration, but it is also possible to *imperatively/procedurally* create a class by calling type() and a function by passing a __call__() to type()'s __dict__ argument. A fully declarative language just turn everything into declarations including the "business logic" of the application (and of course, variable declaration).
From: Nobody on 11 May 2010 16:07
On Tue, 11 May 2010 23:13:10 +1200, Lawrence D'Oliveiro wrote: >> But the beauty is that Python is multi-paradigm ... > > The trouble with “multi-paradigm” is that it offends the zealots on > all sides. Is that how you view people who like languages to exhibit a degree of consistency? Some people would prefer to have a manageable set of rules rather than having to remember the results of all of the possible combinations of interactions between language features. |