[fpc-devel] for-in-index loop

Michael Van Canneyt michael at freepascal.org
Fri Jan 25 19:59:10 CET 2013



On Sat, 26 Jan 2013, Alexander Klenin wrote:

> 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.

I don't see it like that. Donald Knuth declared TeX as finished.
Despite that, it has been doing just fine for its intended purpose.

>> 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.

I didn't say that.

Like I said, I am not against new language features per se.
I just don't think that this one is one that should be added.

>>>> 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:

If I cared about 'usual opinion', I would be using C#.

>> 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.

There is only 1 method:

for i:=0 to I.Count-1.

>> 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.

You want to tell me that

for i:=1 to 10 do
   Writeln(i);

is less clear than

for i in range(1,10)
   printf(i) # or whatever python uses.

For someone versed in Python, I can imagine that probably is so.

But I learned from BASIC, and had absolutely no problem understanding it.

Michael.



More information about the fpc-devel mailing list