Mike Meyer a écrit : > Antoon Pardon <[EMAIL PROTECTED]> writes: > >>Op 2005-10-03, Steven D'Aprano schreef <[EMAIL PROTECTED]>: >> >>>On Mon, 03 Oct 2005 13:58:33 +0000, Antoon Pardon wrote: >> >>Declarations also allow easier writable closures. Since the declaration >>happens at a certain scope, the run time can easily find the correct >>scope when a variable is rebound. > > > If it happens at runtime, then you can do it without declarations: > they're gone by then. Come to think of it, most functional languages - > which are the languages that make the heaviest use of closures - don't > require variable declarations.
Well, can you give a single example of such language ? Because all the functionnal language I know but one do need variable declaration : lisp, scheme, ocaml, haskell do need variable declaration ! Erlang do not ... > > [...] > > > Only in a few cases. Type inferencing is a well-understood > technology, and will produce code as efficient as a statically type > language in most cases. > Type inferencing only works for statically typed languages AFAIK ! In a dynamically typed languages, typing a variable is simply impossible as any function may return a value of any type ! > >>I think language matters shouldn't be setlled by personal preferences. > > > I have to agree with that. For whether or not a feature should be > included, there should either be a solid reason dealing with the > functionality of the language - meaning you should have a set of use > cases showing what a feature enables in the language that couldn't be > done at all, or could only be done clumsily, without the feature. Wrong argument ... with that kind of things, you would just stick with plain Turing machine ... every single computation can be done with it ! > > Except declarations don't add functionality to the language. They > effect the programing process. And we have conflicting claims about > whether that's a good effect or not, all apparently based on nothing > solider than personal experience. Which means the arguments are just > personal preferences. > Well, so why not *allow* for variable declaration ? Languages like Perl does that successfully ... you don't like : you don't do ! you like : you do ! A simple option at the beginning of the file tell the compilor if variable declaration is mandatory or not ! > Until someone does the research to provide hard evidence one way or > another, that's all we've got to work with. Which means that languages > should exist both with and with those features, and if one sides > experiences generalize to the population at large, they alternative > languages will die out. Which hasn't happened yet. > > >>But we should decide what language features are usefull and which are >>not by what some individual can or can't live without. > > > Um - that's just personal preference (though I may have misparsed your > sentence). What one person can't live without, another may not be able > to live with. All that means is that they aren't likely to be happy > with the same programming language. Which is fine - just as no > programming language can do everything, no programming language can > please everyone. > > Antoon, at a guess I'd say that Python is the first time you've > encountered a dynamnic language. Being "horrified" at not having > variable declarations, which is a standard feature of such languages > dating back to the 1950s, is one such indication. Dynamic language and variable declaration are non-related issues ! You can have statically-typed language without variable declaration (i.e. BASIC) and dynamically-typed language with (i.e. Lisp) ! Please, when you says something about languages, at least give 1 name of language asserting what you're saying ! > Dynamic languages tend to express a much wider range of programming > paradigms than languages that are designed to be statically > compiled. Some of these paradigms do away with - or relegate to the > level of "ugly performance hack" - features that someone only > experienced with something like Pascal would consider > essential. Assignment statements are a good example of that. Well, could you be more specific once more ? I can't that many paradigm only available on dynamically typed languages ... beside duck-typing (which is basically a synonym for dynamically-typed) > Given these kinds of differences, prior experience is *not* a valid > reason for thinking that some difference must be wrong. Until you have > experience with the language in question, you can't really decide that > some feature being missing is intolerable. You're in the same position > as the guy who told me that a language without a goto would be > unusable based on his experience with old BASIC, FORTRAN IV and > assembler. After more than two years of Python programming, I still fill the need for variable declarations. It would remove tons of bugs for little works and would also clarify the scope of any single variable. > Pick one of the many languages that don't require declarations. Try > writing a code in them, and see how much of a problem it really is in > practice, rather than trying to predict that without any > information. Be warned that there are *lots* of variations on how > undeclared variables are treated when referenced. Python raises > exceptions. Rexx gives them their print name as a value. Other > languages do other things. > > <mike Well, IMO, worst case is silently give a default value, like PHP (or apparently Rexx) does ... this can hide bugs for month if a single test-case is missing ! Well, in the end, I would really like an *option* at the beginning of a module file requiring variable declaration for the module. It would satisfy both the ones who want and the ones who don't want that ... Pierre -- http://mail.python.org/mailman/listinfo/python-list