Re: [fpc-pascal] Illegal counter variable?

2019-09-09 Thread Markus Greim
James, not every body is using a GHz machine. I am , for example, programming a 80186 in an embedded system with very limited speed an RAM. But I understand thats not a general argument. But look at MISRA C. Its a big set of rules for "real" save C programming, more or less now the stan

Re: [fpc-pascal] Illegal counter variable?

2019-09-09 Thread Markus Greim
AFAIK these is the standard behavior since the first PASCAL versions. We must not change it. It prevents a lot of side effects, and PASCAL is NOT C without brackets! Use while or repeat instead! >From Niklaus Wirths last 2004 Oberon manual: https://people.inf.ethz.ch/wirth/ProgInOberon2004.

Re: [fpc-pascal] Illegal counter variable?

2019-09-09 Thread James Richters
Maybe there's no technical reason it doesn't work... it's just set to not work to make it compatible with other pascal programs? -Original Message- From: fpc-pascal On Behalf Of Mattias Gaertner via fpc-pascal Sent: Monday, September 9, 2019 1:32 PM To: fpc-pascal@lists.freepascal.org C

Re: [fpc-pascal] Illegal counter variable?

2019-09-09 Thread Mattias Gaertner via fpc-pascal
On Mon, 9 Sep 2019 19:27:49 +0200 Bart wrote: > On Mon, Sep 9, 2019 at 4:54 PM Jonas Maebe > wrote: > > > "var i : longint = 0;" is internally handled using the same code > > path as "const i : longint = 0", and typed constants cannot be used > > as counter variables. This is indeed probably a

Re: [fpc-pascal] Illegal counter variable?

2019-09-09 Thread Bart
On Mon, Sep 9, 2019 at 4:54 PM Jonas Maebe wrote: > "var i : longint = 0;" is internally handled using the same code path as > "const i : longint = 0", and typed constants cannot be used as counter > variables. This is indeed probably a bug. D7 does not allow this for global variables: "for loop

Re: [fpc-pascal] Illegal counter variable?

2019-09-09 Thread James Richters
Yes, today such limitations do seem too restrictive, I wonder if the reasons for the restrictions have become obsolete. You would have to have a really slow computer with very limited resources to optimize loops to the point of reducing functionality like this, and the tendency with modern pc's

Re: [fpc-pascal] Very vague gettickcount64 description?

2019-09-09 Thread Zoë Peterson
On 9/8/2019 2:09 AM, Michael Van Canneyt wrote: For relative measurements, units are not needed. A ratio has no units, the only thing that is required is that the units for both measurements are the same (which should be the case on a single platform). That's fair. GetTickCount is also the bes

Re: [fpc-pascal] Illegal counter variable?

2019-09-09 Thread Martin Wynne
On 09/09/2019 15:11, James Richters wrote: If (I>86) And (I<95) then Continue; What does continue do exactly? Loop back to the beginning of the for loop right away? Hi James, Yes in effect -- it jumps forward to the test at the end of a loop. Very useful. See: https://www.freepascal.org/d

Re: [fpc-pascal] Illegal counter variable?

2019-09-09 Thread Jonas Maebe
On 2019-09-09 11:30, James Richters wrote: Can someone please tell me why this happens? Var I : Longint = 0; Begin For I := 1 to 6 Do Writeln(I); End. This gives me : initialize.pas(4,5) Error: Illegal counter variable initialize.pas(6,4) Fatal: There were 1 errors compiling module, stop

Re: [fpc-pascal] Illegal counter variable?

2019-09-09 Thread Bernd Oppolzer
Am 09.09.2019 um 16:11 schrieb James Richters: I just don't see why having the limitation, there is no technical reason that the for loop couldn't change that I can see.. especially since it works in TP mode. The original reason why some Pascal implementations had this limitation: for perfo

Re: [fpc-pascal] Illegal counter variable?

2019-09-09 Thread James Richters
If (I>86) And (I<95) then Continue; What does continue do exactly? Loop back to the beginning of the for loop right away? I didn't even know there was such a command.. it's not mentioned here: https://wiki.lazarus.freepascal.org/FOR..DO only break is mentioned. As I said, there are ways aro

Re: [fpc-pascal] Illegal counter variable?

2019-09-09 Thread DougC
The last messages have wandered off topic somewhat. Can we stick to the original request, which was why the handling of the two declarations differed? Doug C.___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/c

Re: [fpc-pascal] Illegal counter variable?

2019-09-09 Thread Martin Wynne
On 09/09/2019 13:38, James Richters wrote: Var I:Byte; Begin I:=57; For I := I to 100 do Begin If I=87 then I:=95; Write(I,' '); End; End. Why not: Var I:Byte; Begin I:=57; For I := I to 100 do Begin If (I>86) And (I<95) the

Re: [fpc-pascal] Illegal counter variable?

2019-09-09 Thread James Richters
>That page only talks about assigning the loop var *inside* the loop, which is >forbidden. You can re-assign the loop variable if you are in {$Mode TP} it works perfectly fine to re-assign the for variable inside the loop, and I use that extensively, I have TP units specifically so I can do tha

Re: [fpc-pascal] Illegal counter variable?

2019-09-09 Thread James Richters
I don't understand what difference it makes if I assign I :=0 with the variable declaration or If I was using I for something else.. It's irrelevant what the condition of I was before the for loop, just as it's irrelevant that the status of a variable is before you assign it to something.I

Re: [fpc-pascal] Illegal counter variable?

2019-09-09 Thread Mattias Gaertner via fpc-pascal
On Mon, 9 Sep 2019 11:44:05 +0200 SPRL AFOR wrote: > Hi. > > Index variable can neither be initialized nor computed. Read > https://wiki.lazarus.freepascal.org/FOR..DO That page only talks about assigning the loop var *inside* the loop, which is forbidden. James question is about the differen

Re: [fpc-pascal] Illegal counter variable?

2019-09-09 Thread SPRL AFOR
Hi. Index variable can neither be initialized nor computed. Read https://wiki.lazarus.freepascal.org/FOR..DO Antonio Le 09/09/2019 à 11:30, James Richters a écrit : Can someone please tell me why this happens? Var I : Longint = 0; Begin For I := 1 to 6 Do Writeln(I); End. This give

[fpc-pascal] Illegal counter variable?

2019-09-09 Thread James Richters
Can someone please tell me why this happens? Var I : Longint = 0; Begin For I := 1 to 6 Do Writeln(I); End. This gives me : initialize.pas(4,5) Error: Illegal counter variable initialize.pas(6,4) Fatal: There were 1 errors compiling module, stopping initialize.pas(0) Fatal: Compilation ab

Re: [fpc-pascal] Challenge accepted

2019-09-09 Thread Joost van der Sluis
Hi all, I've put some code, documentation and examples online for the serialization-library. Very rough, but I think it shows my ideas. You can find it here: https://wiki.freepascal.org/cnocstream The name, classnames etc may change. Everyone with good ideas, they are welcome. There is n