[fpc-devel] for-in-index loop
Alexander Klenin
klenin at gmail.com
Fri Jan 25 19:49:32 CET 2013
On Sat, Jan 26, 2013 at 4:38 AM, Michael Van Canneyt
<michael at freepascal.org> wrote:
>>> WITH EACH ADDITIONAL "FEATURE" WE ARE BUTCHERING PASCAL MORE AND MORE.
>> Hm... Do not you think this is a bit of an overstatement?
> No, not really. I really feel that we are deviating a lot from what pascal stands for.
If you mean the original Wirth's definition -- then yes, of course any
change to the language
does move it away from the initial state.
However, I am strongly against such a "walled garden" approach to the
language design.
The state of the art in programming languages has advanced
considerably in the last 40 years,
and the set of features expected from modern language has become quite
different too.
I disagree that freezing at Wirth's (or current, or any fixed)
definition is a useful plan for
Pascal development.
>
> You can always find things missing in any language.
> I miss compilation, and other low-level things in Python.
> It depends on what you value.
I certainly agree that Pascal has some advantages -- and they often
outweigh disadvantages.
Otherwise, I would be in Python's mailing list now, arguing to add
some of the Pascal's features :)
However, this does not mean that disadvantages should be just ignored.
>>> Pascal needs more useful libraries.
>> It is important to note that default libraries ARE part of the language
> You are wrong there.
Well, this is a matter of opinion of course, but note that your
opinion on this topic
is again different from the usual one:
Python: google "batteries included"
C++: http://stackoverflow.com/questions/5460541/is-the-c-standard-library-part-of-the-c-language
Java: for example, a string literal is defined as an instance of the
java.lang.String class
PHP: it is of course bad design, but for a long time there was not
even a notion of "library", all standard methods were accessible
directly at language level
Pascal: note that both the original definition and the ISO standard
include a set of input/output and mathematical functions,
which comprise the standard library. It is a poor library, but
nevertheless included in the language definition.
... etc.
> I am talking about libraries that perform actual tasks. Not containers.
> PDF generating, https protocol and whatnot. Those are definitely not part of
> the language.
Yes, and even those. For example, lack of network support in C++
standard library is
widely considered a disadvantage for the language.
Conversely, presence of such support in Go and Python is hailed as
good language feature.
Note that technically, of course, the distinction exist -- what I am
talking about is that
from user's POV they are the same.
> The student will have to remember 4 different syntaxes.
>
> For a:=b to c do
> for a:=b downto c do
> for a in b do
> for a in b index c do
>
> Concise ? I don't think so.
Compared to the 10 methods of iterating over container just in the current
FPC+Lazarus code? Yes, I think this *is* concise and clear.
> And let us not forget that the last one is a highly abstract one, because
> you need a lot of concepts before you can explain why it is needed and how
> to use it. The first one, by contrast, is so simple that any 12-year old can
> get it.
Actually, I do teach young students (12 years old is somewhat too
young, but 13-14 is usual).
I can tell you they have *more* trouble with Pascal style of loop with indexing
as compared to Python's for-each with index.
--
Alexander S. Klenin
More information about the fpc-devel
mailing list