free pascal vs turbo pascal - range checking 
Author Message
 free pascal vs turbo pascal - range checking

Interesting behavior difference between free Pascal and borland pascal
in runtime error 201

program range;
var p  : integer;
    j  : integer;
    cv : array[1..10] of string; { 10 max }
    sr : string;

label 1;

begin

sr := '1 2 3 4 5 6 7 8 9 10 11 ';

j := 0;
1:
p := pos(' ',sr);
if p > 0 then
  begin
  j := j+1;
  cv[j] := copy(sr,1,(p-1));
  delete(sr,1,p);
writeln(sr,' ',length(sr));
  goto 1;
  end;

writeln;
writeln(j,' ',j+1);

end.



Wed, 18 Jun 1902 08:00:00 GMT  
 free pascal vs turbo pascal - range checking

Quote:

> Interesting behavior difference between free pascal and borland pascal
> in runtime error 201

> program range;
> var p  : integer;
>     j  : integer;
>     cv : array[1..10] of string; { 10 max }
>     sr : string;

> label 1;

> begin
> sr := '1 2 3 4 5 6 7 8 9 10 11 ';
> j := 0;
> 1:
> p := pos(' ',sr);
> if p > 0 then
>   begin
>   j := j+1;
>   cv[j] := copy(sr,1,(p-1));
>   delete(sr,1,p);
> writeln(sr,' ',length(sr));
>   goto 1;
>   end;
> writeln;
> writeln(j,' ',j+1);
> end.

It is of very little use to compare two Pascal compilers with a
poor BASIC program, say a program with BASIC semantics using a few
Pascal keywords! ( :-o)
--
Franz Glaser, Glasau 3, A-4191 Vorderweissenbach Austria +43-7219-7035-0
Muehlviertler Elektronik Glaser.  Industrial control and instrumentation
http://members.eunet.at/meg-glaser/    http://members.xoom.com/f_glaser/
http://www.geocities.com/~franzglaser/            http://start.at/bedarf


Wed, 18 Jun 1902 08:00:00 GMT  
 free pascal vs turbo pascal - range checking

Quote:
>It is of very little use to compare two Pascal compilers with a
>poor BASIC program, say a program with BASIC semantics using a few
>Pascal keywords! ( :-o)

1. I didn't even understand the example (didn't try really, was too hard)
2. Although I hate Ba_sick_, I have to defend it:
    There are statements like SUB, FUNCTION, DO/LOOP,
    WHILE/WEND, DIM etc.

   The thing is, it wasn't only a poor _BASIC_ program
   it was a very poor program in general.

   Programs are mostly as bad as their programmers' skills.
   Note that the "programmer" himself may be a nice person,
   therefore the "skills".

--

  [ Homepage contents: About Me - TP,TASM,Delphi descriptions - My projects - ... ]
  [ Homepage German only - vote for an English version; use my E-Mail above       ]



Wed, 18 Jun 1902 08:00:00 GMT  
 free pascal vs turbo pascal - range checking
How did you two guys get so arrogant??

First, I have never written a basic program!! lol
I program exlusively in APL and Turbo/Borland Pascal 7.0 and now free
pascal.
I did a lot of programming in ADA early on but ADA died a quick death.
I learned Delpi 2.0 but have no need for that on LINUX.
free pascal seems the way to go for the future on LINUX.

Second, I have been converting hundreds of thousands of lines of code
from turbo to free pascal and have found many interesting differences -
some trivial and some significant - I thought this was of significance
to REAL PROGRAMMERS!! lol

Third, the program is pieces (snipets) of a larger program that gave me
inconsistant results and was easily fixed to run right.

I posted the uncorrected parts here to show that free pascal does not
generate a run time error while turbo pascal does with the same code -
it has enough code to show this.

I was hoping someone with some knowledge of both would see this and help
me to get the same behavior from both compilers - maybe with some
switches in the compiler config file

I would like both of you arrogant SOB's to rewrite this little code so
it looks like 'PASCAL' and looks like a "GOOD" program - you phonies!!
lol

By the way - I'll bet neither of you are even smart enough to know what
is wrong with this program snipet!!

After going back through your posts, Herr Ing it seems you have gained a
real self importance by assisting newbies with their homework
assignments!! Keep up the good work!! lol

enztec

Quote:

> Interesting behavior difference between free pascal and borland pascal
> in runtime error 201

> program range;
> var p  : integer;
>     j  : integer;
>     cv : array[1..10] of string; { 10 max }
>     sr : string;

> label 1;

> begin

> sr := '1 2 3 4 5 6 7 8 9 10 11 ';

> j := 0;
> 1:
> p := pos(' ',sr);
> if p > 0 then
>   begin
>   j := j+1;
>   cv[j] := copy(sr,1,(p-1));
>   delete(sr,1,p);
> writeln(sr,' ',length(sr));
>   goto 1;
>   end;

> writeln;
> writeln(j,' ',j+1);

> end.



Wed, 18 Jun 1902 08:00:00 GMT  
 free pascal vs turbo pascal - range checking
Hi,


Quote:
> Interesting behavior difference between free pascal and borland pascal
> in runtime error 201

FPC doesn't produce a runtime error. Your program, however, is designed
clumsy, as it doesn't show how FPC does react to your range violation.
Had you initialized sr to '1 2 3 4 5 6 7 8 9 10 11 12 13 ', you would
have noticed that under FPC, j will not exceed 11.

Quote:
> j := 0;
> 1:
> p := pos(' ',sr);
> if p > 0 then
>   begin
>   j := j+1;
>   cv[j] := copy(sr,1,(p-1));
>   delete(sr,1,p);
> writeln(sr,' ',length(sr));
>   goto 1;
>   end;

Oh, my god! Why didn't you use a while loop like this?

j := 0;
p := Pos(' ',sr);
while p > 0 do
begin
   Inc(j);
   cv[j] := Copy(sr,1,(p-1));
   Delete(sr,1,p);
   writeln(...);
   p := Pos(' ',sr);
end;

I mean, that's what we use Pascal for, isn't it? Otherwise you could have
used B?sik, as pointed out by other posters.

 - Sebastian

--
This signature is under construction - be sure to visit back often!



Wed, 18 Jun 1902 08:00:00 GMT  
 free pascal vs turbo pascal - range checking

Quote:

> Interesting behavior difference between free pascal and borland pascal
> in runtime error 201

[program cut]

Which version of FPC are you using? In the latest snapshots (available
from the development section of the website), this bug is already fixed
anyway:

***
2 3 4 5 6 7 8 9 10 11  22
3 4 5 6 7 8 9 10 11  20
4 5 6 7 8 9 10 11  18
5 6 7 8 9 10 11  16
6 7 8 9 10 11  14
7 8 9 10 11  12
8 9 10 11  10
9 10 11  8
10 11  6
11  3
Run time error  201 at 0x00002471
  0x0000AFBE
  0x00002001
***

Jonas



Wed, 18 Jun 1902 08:00:00 GMT  
 free pascal vs turbo pascal - range checking
Hi,


Quote:
> How did you two guys get so arrogant??

I don't know if you are referring to me, but I hope not!!

Quote:
> First, I have never written a basic program!! lol

Never ever use the Goto. If you do, the result is nothing more than a basic
program with Pascal syntax, as one of the "arrogant guys" pointed out.

Quote:
> Second, I have been converting hundreds of thousands of lines of code
> from turbo to free pascal and have found many interesting differences -
> some trivial and some significant - I thought this was of significance
> to REAL PROGRAMMERS!! lol

"Real Programmers Don't Use Pascal" (see
http://www.mcs.brandonu.ca/~ennsnr/Humor/real-progstory.html )

Quote:
> I was hoping someone with some knowledge of both would see this and help
> me to get the same behavior from both compilers - maybe with some
> switches in the compiler config file

Then _why_the_hell_ didn't you write that? Use the option -Cr and FPC range
checking will be switched on, causing your program to become 201 compliant.
Oh, and RTFM.

Quote:
> By the way - I'll bet neither of you are even smart enough to know what
> is wrong with this program snipet!!

This is totally uncalled for! Your program reminded me of my Basic period,
which is years ago. You should take their criticism serious.

 - Sebastian

--
YOUR AD HERE!



Wed, 18 Jun 1902 08:00:00 GMT  
 free pascal vs turbo pascal - range checking
Sorry - My mistake for not Reading The F(antastic) Manual.  It appears
to be complete indeed.

If you clever programmers don't mind please look at my first post which
no one has responded to :
"Subject: Re: freepascal - Ctrl Break displayed as ^C even when trapped"
I've supplied code for that too  - please ridicule it also - as long as
you can help me solve it.!!! lol

To my three new programming buddies (who have ridiculed my entire
programming style by looking at a single 22 line snipet program) and in
defence of the lovely and {*filter*} "goto" the following is ranted :

Why this hostility toward Basic and 'Basic style coding'? It makes as
much sense as saying that German is a better language than French.
(though it is);

I never took Basic seriously because it was originally an interpreted
language, (you couldn't distribute your program without giving the
source code too - same as APL) and way to slow executing - but not
because of it's simple but effective style.

You may think you are so much better a programmer than I am because you
do not use gotos in your higher level coding but if you think "gotos"
are not there in your assembled or object code, you are deluding
yourself. Check an assembler manual and see how many different types of
jump statements there are - and all are used. Code is code and it has to
be done somewhere - it isn't magic. You are still using "gotos" just not
typing them into an editor.

Regarding the darlings of "structured programming" : the "repeat -
until" or "do - while" statements etc - Do you think they are not build
up of "gotos" in order to function??? I avoid these statements at all
cost - because they are just coding substitutes for the goto - there
really is no need for them. (is this ludite reverse structured
programming?)

This whole "structured programming nonsense" (no use of gotos) is a
pseudo-intelectual canard and was the forerunner of 'political
correctness' as far as I'm concerned - it only exists in the arrogant
minds of it's proponents - the human need to be superior and smarter
than others and to let them know it. Nothing more or less than a
childish power trip.

I've never been impressed with someone who has shown how clever he/she
is in writing source code without gotos because they usually have
reworked the code for who knows how long - all I care about is how
clever your executable image (.exe) is. Does it do what it is suppose to
do without creating other problems.

My idea of real cleverness is how well you can write 500 - 1000 lines
of  bug free complicated code in a day on the fly - not being able to
sit down and rework and rework your (factorial) code so it is goto free
to show your cleverness to impress people who don't realize how long it
took you to rework the code.

I've also found that no one in the real world really cares how clever
your code is as long as it works and doesn't need to be rewritten and it
won't cause a legal liabilty.

Only in academia does this 'clever coding' have a purpose - like
recursive factorial problems- for simple homework assignments -  and
impressing the teacher.

Now if only some grand Herr Professor could combine a recursive
factorial program with calculating Pi to the billionth decimal - we
would have something - a professor with tenure! lol

If you have ever really written a complicated program that has a real
world application you would know there is sometimes no other way out of
loop structure then a strategically placed goto!

Straight forward direct code has to run faster with less problems than
code written for its cleverness, has to have less logical bugs and has
to take less time to write.

I have just recompiled hundreds of thousands of lines of my genetic
enzyme design code using free pascal (fpc) to run on a LINUX/Mandrake
6.0 system (and boy am I glad it is such a fantastic compiler that
handles gotos so efficiently and all the other aspects of what can only
be called my poor coding style). There were only two problems with my
code. The one that started this thread and my ^Break problem.
Do you think you could write hundreds of thousands of lines of "no goto
code" and come back four and 1/2 years later and quickly understand and
get reaquainted with your code again - I can and did.

Beware new controversy here : I have written programs for 30 years and
have never written a program using pointers either - another
academically useless exercise!. I know this will upset all the "arrogant
clever programmers" also. I just have that feeling.

Please respond in all your severity but to really make me feel bad
please tell me what is wrong with my ^Break code program running under
dos - under LINUX it works find ! and how to fix it - lol

long live the goto!!

enztec

PS Anyone know of a 32 bit Basic Compiler that will run under Linux??? I
think it is time I learned a new language.

Quote:

> Hi,


> > How did you two guys get so arrogant??

> I don't know if you are referring to me, but I hope not!!

> > First, I have never written a basic program!! lol

> Never ever use the Goto. If you do, the result is nothing more than a basic
> program with Pascal syntax, as one of the "arrogant guys" pointed out.

> > Second, I have been converting hundreds of thousands of lines of code
> > from turbo to free pascal and have found many interesting differences -
> > some trivial and some significant - I thought this was of significance
> > to REAL PROGRAMMERS!! lol

> "Real Programmers Don't Use Pascal" (see
> http://www.*-*-*.com/ ~ennsnr/Humor/real-progstory.html )

> > I was hoping someone with some knowledge of both would see this and help
> > me to get the same behavior from both compilers - maybe with some
> > switches in the compiler config file

> Then _why_the_hell_ didn't you write that? Use the option -Cr and FPC range
> checking will be switched on, causing your program to become 201 compliant.
> Oh, and RTFM.

> > By the way - I'll bet neither of you are even smart enough to know what
> > is wrong with this program snipet!!

> This is totally uncalled for! Your program reminded me of my Basic period,
> which is years ago. You should take their criticism serious.

>  - Sebastian

> --
> YOUR AD HERE!



Wed, 18 Jun 1902 08:00:00 GMT  
 free pascal vs turbo pascal - range checking

Quote:
>If you clever programmers don't mind please look at my first post which
>no one has responded to :
>"Subject: Re: freepascal - Ctrl Break displayed as ^C even when trapped"
>I've supplied code for that too  - please ridicule it also - as long as
>you can help me solve it.!!! lol

Not using FPC, I cannot comment - perhaps one of the coders of FPC might
do so when they have time. Remember that you cannot be guaranteed fast
answers to questions on Usenet. It may take a bit of time for a response
to be forthcoming - especially from those who perhaps only read a group
every few days.
Quote:

>To my three new programming buddies (who have ridiculed my entire
>programming style by looking at a single 22 line snipet program) and in
>defence of the lovely and {*filter*} "goto" the following is ranted :

>Why this hostility toward Basic and 'Basic style coding'?

>You may think you are so much better a programmer than I am because you
>do not use gotos in your higher level coding but if you think "gotos"
>are not there in your assembled or object code, you are deluding
>yourself. Check an assembler manual and see how many different types of
>jump statements there are - and all are used. Code is code and it has to
>be done somewhere - it isn't magic. You are still using "gotos" just not
>typing them into an editor.

Yes they are there at the *assembler* level with LOOP, JNE etc *but* the
point is that repeat..until, for ..do, etc. are far *clearer* data
structures to use than a mess of GOTO statements and are likely to
generate better code.

Quote:

>If you have ever really written a complicated program that has a real
>world application you would know there is sometimes no other way out of
>loop structure then a strategically placed goto!

boolean tests until V7 of T/BP with break and continue were perfectly
adequate for the task.

Quote:
>Do you think you could write hundreds of thousands of lines of "no goto
>code" and come back four and 1/2 years later and quickly understand and
>get reaquainted with your code again

Yes. Commenting your code is very useful.

Quote:

>Beware new controversy here : I have written programs for 30 years and
>have never written a program using pointers either - another
>academically useless exercise!.

So you have never needed to use the heap for data then and only write
programs that need a max of [just under] 64K of data ?

--
Pedt
If the terminally clueless had an extra brain cell it would be lonely.

As x-posted thread, clpb mini-FAQ sig in abeyance to avoid confusion



Wed, 18 Jun 1902 08:00:00 GMT  
 free pascal vs turbo pascal - range checking

Quote:
>If you clever programmers don't mind please look at my first post which
>no one has responded to :
>"Subject: Re: freepascal - Ctrl Break displayed as ^C even when trapped"
>I've supplied code for that too  - please ridicule it also - as long as
>you can help me solve it.!!! lol

It's gone.

Quote:
>To my three new programming buddies (who have ridiculed my entire
>programming style by looking at a single 22 line snipet program) and in
>defence of the lovely and {*filter*} "goto" the following is ranted :

Later you state you don't use those HLL features - first impression correct.

Quote:
>Why this hostility toward Basic and 'Basic style coding'? It makes as
>much sense as saying that German is a better language than French.
>(though it is);

That's what I said. But nevertheless, Basic is crap.

Quote:
>You may think you are so much better a programmer than I am because you
>do not use gotos in your higher level coding but if you think "gotos"
>are not there in your assembled or object code, you are deluding
>yourself. Check an assembler manual and see how many different types of
>jump statements there are - and all are used. Code is code and it has to
>be done somewhere - it isn't magic. You are still using "gotos" just not
>typing them into an editor.

Therefore it is called HLL. You do not say how to do, but what to do. That's
it. You don't like repeat/until, but then, you want to have the rest of the
HLL. As I say: all or nothing (ask Cher). Either you use all HLL functions
when enjoying your HLL or you use ASM.
BTW: Saying the compiler what you want, it can better optimize your code.
There may be differences between optimizing a jump and a loop.

Quote:
>Regarding the darlings of "structured programming" : the "repeat -
>until" or "do - while" statements etc - Do you think they are not build
>up of "gotos" in order to function???

See above. May very well be.

Quote:
>I avoid these statements at all
>cost - because they are just coding substitutes for the goto - there
>really is no need for them. (is this ludite reverse structured
>programming?)

Completely incorrect. They describe what you want, not how you want it.
They may be better optimized.

How about for/to/do? It should be very much faster then if/goto.

Quote:
>I've never been impressed with someone who has shown how clever he/she
>is in writing source code without gotos because they usually have
>reworked the code for who knows how long - all I care about is how
>clever your executable image (.exe) is. Does it do what it is suppose to
>do without creating other problems.

I don't have to rework my code that it works without any goto - because I
don't use it.

Quote:
>My idea of real cleverness is how well you can write 500 - 1000 lines
>of  bug free complicated code in a day on the fly - not being able to
>sit down and rework and rework your (factorial) code so it is goto free
>to show your cleverness to impress people who don't realize how long it
>took you to rework the code.

Blah blah blah.

Quote:
>I've also found that no one in the real world really cares how clever
>your code is as long as it works and doesn't need to be rewritten and it
>won't cause a legal liabilty.

The maintenance of your program will be worse if you don't use the structures
Wirth especially wanted to implement in TP. Pascal was invented by him and he
had the idea of goto-less programming. (Correct me if I am wrong.)
If you don't like his ideas, go play with Basic.

Quote:
>Only in academia does this 'clever coding' have a purpose - like
>recursive factorial problems- for simple homework assignments -  and
>impressing the teacher.

Blah.

Quote:
>Now if only some grand Herr Professor could combine a recursive
>factorial program with calculating Pi to the billionth decimal - we
>would have something - a professor with tenure! lol

??? Don't understand

Quote:
>If you have ever really written a complicated program that has a real
>world application you would know there is sometimes no other way out of
>loop structure then a strategically placed goto!

Or a Break. Or a little thinking. I prefer Break.

Quote:
>Straight forward direct code has to run faster with less problems than
>code written for its cleverness, has to have less logical bugs and has
>to take less time to write.

That's completely nonsense. That your code is potentially incorrect can
be seen in the fact I need much more time to read/understand it.

Quote:
>I have just recompiled hundreds of thousands of lines of my genetic
>enzyme design code using free pascal (fpc) to run on a LINUX/Mandrake
>6.0 system (and boy am I glad it is such a fantastic compiler that
>handles gotos so efficiently and all the other aspects of what can only
>be called my poor coding style).

Too much luck you don't deserve. {hmm.. the dictionary also lists merit}

Quote:
>Do you think you could write hundreds of thousands of lines of "no goto
>code" and come back four and 1/2 years later and quickly understand and
>get reaquainted with your code again - I can and did.

Miracle. If I wrote such code, I would definitely not.
1. "no goto" is shorter (think of those labels ...)
2. "no goto" code is much easier to understand

Quote:
>Beware new controversy here : I have written programs for 30 years and
>have never written a program using pointers either - another
>academically useless exercise!. I know this will upset all the "arrogant
>clever programmers" also. I just have that feeling.

30 years for nothing.
1. I use pointers - using procedural pointers for your inner loop can fasten
   your code because you don't have to use so many ifs.
2. OOP without pointers - bang!
3. var-parameters without pointers - bang!
   (Do you know var-parameters? Do you use them - you use pointers.
    And that after 30 years of programming!)

Quote:
>long live the goto!!

Long live the queen ... if all that wouldn't be so sad I'd call you funny.

Quote:
>enztec

Pfhfhfh!

Quote:
>PS Anyone know of a 32 bit Basic Compiler that will run under Linux??? I
>think it is time I learned a new language.

Yes - but asm. Basic has not deserved you.
{hmm.. the dictionary also lists merit}

--

  [ Homepage contents: About Me - TP,TASM,Delphi descriptions - My projects - ... ]
  [ Homepage German only - vote for an English version; use my E-Mail above       ]



Wed, 18 Jun 1902 08:00:00 GMT  
 free pascal vs turbo pascal - range checking

Quote:

> If you clever programmers don't mind please look at my first post which
> no one has responded to :
> "Subject: Re: freepascal - Ctrl Break displayed as ^C even when trapped"
> I've supplied code for that too  - please ridicule it also - as long as
> you can help me solve it.!!! lol

I cannot recall having seen this post in comp.lang.pascal.borland, so your
argument (complaint, rather) is invalid in this newsgroup.

Quote:
> To my three new programming buddies (who have ridiculed my entire
> programming style by looking at a single 22 line snipet program) and in
> defence of the lovely and {*filter*} "goto" the following is ranted :

The short snippet actually reveals a lot about your intricate programming style.
You use a goto and an if where a while-loop would do the job. That does not
really contribute to the readability of your program.
I'm sure some people would gladly have helped you, but it seems that you first
need to learn structured programming before anything else. Don't rebuff comments
about your programming style. They are meant to help you improve your style, not
to slight you. Once your program is comprehensible, you can go on to the next
problem.

Quote:
> Why this hostility toward Basic and 'Basic style coding'?

I have yet to see a (serious) Basic program which doesn't make use of the goto
instruction. It is basically (excuse the pun) useless since it can always be
replaced by adequate loops which are far more readable and flexible. Maybe you
can give an example where goto is indispensable?

Quote:
> It makes as
> much sense as saying that German is a better language than French.
> (though it is);

You contradict yourself and you have probably not reflected much before typing
this.

Quote:
> You may think you are so much better a programmer than I am because you
> do not use gotos in your higher level coding but if you think "gotos"
> are not there in your assembled or object code, you are deluding
> yourself. Check an assembler manual and see how many different types of
> jump statements there are - and all are used.

A compiler is forced to use jumps when translating loops to assembly language
since the processor does not have a true loop instruction. The opcode "loop" does
exist, but it cannot be used for each type of high-level loop.

Quote:
> Regarding the darlings of "structured programming" : the "repeat -
> until" or "do - while" statements etc - Do you think they are not build
> up of "gotos" in order to function???

The resulting binary files contains jumps where the source code contains loop
statements - of course. The reason why loop structures are preferred to goto is
that they are much more readable and flexible, thereby making source code much
easier to understand and maintain.
When you use goto, you have to scroll. You have to analyse each of the
if-instructions that determine whether a jump will take place or not. All that
can be written in one single line using a loop.

Here is an example to remove leading spaces from a string, but not more than 5:

var
  s : string;
begin
  while s[1] = ' ' do delete(s, 1, 1)
end.

And the same using goto:

label l1, l2;
var
  s : string;
begin
l1:
  if s[1] = ' ' then delete(s, 1, 1) else goto l2
  goto l1
l2:
end;

Quote:
> I avoid these statements at all
> cost - because they are just coding substitutes for the goto - there
> really is no need for them. (is this ludite reverse structured
> programming?)

True. There is indeed no need for them; we could rewrite all programs to use goto
instead of loops. They would be more prone to contain bugs, harder to maintain
and incomprehensible.

Quote:
> I've never been impressed with someone who has shown how clever he/she
> is in writing source code without gotos because they usually have
> reworked the code for who knows how long

Wrong. It certainly doesn't take more time to write a program which is entirely
controled by loops than to write a program that teems with goto instructions once
you know how to use loops and what each of them is capable of doing.

Quote:
> - all I care about is how
> clever your executable image (.exe) is. Does it do what it is suppose to
> do without creating other problems.

Since loops are translated to a jumps just like goto, then why not use loops?

Quote:
> My idea of real cleverness is how well you can write 500 - 1000 lines
> of  bug free complicated code in a day on the fly - not being able to
> sit down and rework and rework your (factorial) code so it is goto free
> to show your cleverness to impress people who don't realize how long it
> took you to rework the code.

Actually, a program is more likely to be bug free if it does not contain goto
instructions. It is not the loops that render a program buggy, it is still the
programmer. And if the programmer does not grasp his own code, he automatically
tends to write faulty code.

Quote:
> I've also found that no one in the real world really cares how clever
> your code is as long as it works and doesn't need to be rewritten and it
> won't cause a legal liabilty.

If a bug is found only a few months after the program was released, the
programmer needs to review his code. He needs to understand the code he wrote a
few months ago.

Quote:
> If you have ever really written a complicated program that has a real
> world application you would know there is sometimes no other way out of
> loop structure then a strategically placed goto!

You can use the procedure break to exit from a loop. Still no need for goto.

Quote:
> Straight forward direct code has to run faster with less problems than
> code written for its cleverness, has to have less logical bugs and has
> to take less time to write.

True. In how far do loops prevent you from creating a powerful and fast program?

Quote:
> Beware new controversy here : I have written programs for 30 years and
> have never written a program using pointers either - another
> academically useless exercise!. I know this will upset all the "arrogant
> clever programmers" also. I just have that feeling.

I guess your applications often stopped with a "Not enough memory" message. Don't
tell me that 64k have always sufficed; if so you have certainly not written large
programs but just some petty programs.

Quote:
> Please respond in all your severity but to really make me feel bad

Nobody wants you to feel bad. You are the one who rebuffs suggestions. You are
paranoid.


Wed, 18 Jun 1902 08:00:00 GMT  
 free pascal vs turbo pascal - range checking
Matthias

Here is the code from my first post that you said was gone - have a look

Quote:

> Hello

> I have just converted a large Borland Pascal 7.0 program to run under
> LINUX using freepascal - and the Ctrl Break is displayed as a '^C' -
> even after trapping as chr(0),chr(0)

> Here is code with shows the problem - compile with freepascal and then
> borland/turbo pascal to see the difference in handling :
> (^Break is Control Break key combination)

> program breakey; { fpc and bpc compile - handle ^Break differently }
> uses Crt;
> var ch : char;

> begin
> checkbreak := false;   { ^Break checking off }
> { checkbreak := true; } { ^Break checking on - default }

> writeln;
> write('Enter ^Break Key : ');

> ch := readkey;

> if ch = chr(0) then
>   begin
>   write('chr(',ord(ch),') ');
>   ch := readkey;
>   end;

> writeln('chr(',ord(ch),') ',ch);

> end.

New note : the problem shows up only when run under Dos.

About the range checking code Matthias Bchse wrote :

Quote:
> ... That your code is potentially incorrect can be seen in the fact I
> need much more time to read/understand it.

Is it the goto statement that is giving you the trouble?? lol
I think this statement of your speaks very clearly about your true
capabilities and why you had to attack my programming style rather than
being able to help with the coding problem it presented at the time.

Quote:
> Too much luck you don't deserve. {hmm.. the dictionary also lists merit}

{*filter*} {*filter*}
luck has nothing to do with the fact that all my programs compiled the
first time using free pascal (fpc) - though with the two run time
problems posted here - I attribute all to the fact that fpc is a well
written compiler.

I think you might mean my bad luck of having you respond in such a {*filter*}
personal way to my simple posting of code here in a programmers
newsgroup!!

Quote:
> 1. "no goto" is shorter (think of those labels ...)

Didn't they teach you that you can put code on a label statement??
like :
4: if (mathias <> student) then enztec_would_be_real_surprised := true;

Speaking of this : a repeat/until would actually add an extra line in
the coding over a if/then/goto statement and label statement
combination. You can do a logic step on the 'label' line and the 'if'
line.

Quote:
> {hmm.. the dictionary also lists merit}

it also lists "arrogant"


Wed, 18 Jun 1902 08:00:00 GMT  
 free pascal vs turbo pascal - range checking

Quote:
> So you have never needed to use the heap for data then and only write
> programs that need a max of [just under] 64K of data ?

Absolutely correct - my largest data structure in any one
procedure/function or program is   var sr : string ;
Remember DNA only has 4 bases - a modified binary code - I use the
Genbank data base as my "file" system and it only consists of text files
- at the most 80 characters a line! so my var sr : string (which is
actually var sr : string[255];)  is major overkill !!!

I started this programming when 256 K bytes of RAM (262144 bytes) cost
over $3000 on early UNIX computers - so I never had much to work with to
begin with. With a multiuser BSD UNIX system running and the Silicon
Valley Software (SVS) Pascal Compiler running there was not much memory
left for programming.

Quote:
> Yes they are there at the *assembler* level with LOOP, JNE etc *but* the
> point is that repeat..until, for ..do, etc. are far *clearer* data
> structures to use than a mess of GOTO statements and are likely to
> generate better code.
> Yes. Commenting your code is very useful.

I think it is far easier to locate code by looking for a unique number -
usually in order running down the program - like '33:' then to read
every comment { I do love to comment though } - doesn't every 'repeat'
or 'for' look the same?

Quote:
> Pedt
> If the terminally clueless had an extra brain cell it would be lonely.

{*filter*} {*filter*}


Wed, 18 Jun 1902 08:00:00 GMT  
 free pascal vs turbo pascal - range checking
Hi,


Quote:
> I never took Basic seriously because it was originally an interpreted
> language, (you couldn't distribute your program without giving the
> source code too - same as APL) and way to slow executing - but not
> because of it's simple but effective style.

Are we talking about the same language? The Basic I know doesn't even
support subprograms, and therefore recursion is hell.

Quote:
> Regarding the darlings of "structured programming" : the "repeat -
> until" or "do - while" statements etc - Do you think they are not build
> up of "gotos" in order to function??? I avoid these statements at all
> cost - because they are just coding substitutes for the goto - there
> really is no need for them. (is this ludite reverse structured
> programming?)

So you say that the tools of structured programming are coding substitutes
for goto - to which I agree. They are just another - IMO, a better - way
to formulate loops that would otherwise have been constructed out of goto
statements. So, besides being somewhat academic, they don't do you any
harm, right? But then you say you avoid them *at all costs* ! Why, for
heaven's sake? What do you gain for that cost?

Quote:
> This whole "structured programming nonsense" (no use of gotos) is a
> pseudo-intelectual canard and was the forerunner of 'political
> correctness' as far as I'm concerned - it only exists in the arrogant
> minds of it's proponents - the human need to be superior and smarter
> than others and to let them know it. Nothing more or less than a
> childish power trip.

You miss all points, being impolite at the same time. I find structured
code much easier to read, and so do quite a lot of people. The example
we are talking about, your program as you posted it, can without problems
be changed to use a while loop: Nothing lost, readability enhanced. You
probably think that loop invariants are also an academic buzzword, so I
won't go into that, but that would be another very strong argument for
structured loops.

Quote:
> Straight forward direct code has to run faster with less problems than
> code written for its cleverness, has to have less logical bugs and has
> to take less time to write.

There should be little performance differences whether you use the
language's constructs or do them yourself, despite the fact that the
latter may be slower because you might foil the compiler's optimizing
strategies. Bugs are easier to find in structured code, because it is
easier to read. And if you need more time to write structured programs,
well, I can't confirm that.

Quote:
> Do you think you could write hundreds of thousands of lines of "no goto
> code" and come back four and 1/2 years later and quickly understand and
> get reaquainted with your code again - I can and did.

That is indeed a hard task, but it is certainly easier without gotos
hopping around all the time. As a side note, you always complain about
others being so vain about their programming skills, but you can't stop
telling your heroic coding stories...

Quote:
> Beware new controversy here : I have written programs for 30 years and
> have never written a program using pointers either - another
> academically useless exercise!. I know this will upset all the "arrogant
> clever programmers" also. I just have that feeling.

What you have is no clue. Academics dislike pointers. They're low-level
stuff, disgusting for hard-core academics :-) I wonder, though, how you
allocate dynamic memory without pointers.

 - Sebastian

--
YOUR AD HERE!



Wed, 18 Jun 1902 08:00:00 GMT  
 free pascal vs turbo pascal - range checking
Dear Enztec (BTW: What's your mission?),

Quote:
>> ... That your code is potentially incorrect can be seen in the fact I
>> need much more time to read/understand it.
>Is it the goto statement that is giving you the trouble?? lol
>I think this statement of your speaks very clearly about your true
>capabilities and why you had to attack my programming style rather than
>being able to help with the coding problem it presented at the time.

Could you read your mothertongue when it is printed all in caps and
italic? Or in a totally ornamentic font? Or when (this is your case)
some 15th century words are used?

Quote:
>I think you might mean my bad luck of having you respond in such a {*filter*}
>personal way to my simple posting of code here in a programmers
>newsgroup!!

I only meant your programming style, I did never talk about you.
At least in this case, I separate that.

Quote:
>> 1. "no goto" is shorter (think of those labels ...)
>Didn't they teach you that you can put code on a label statement??
>like :
>4: if (mathias <> student) then enztec_would_be_real_surprised := true;

They did not teach me because I am 16 and you are right: no student.
What about: Label l1,l2,l3,l4,l5,l6
Adds an extra line, too.

--

  [ Homepage contents: About Me - TP,TASM,Delphi descriptions - My projects - ... ]
  [ Homepage German only - vote for an English version; use my E-Mail above       ]



Wed, 18 Jun 1902 08:00:00 GMT  
 
 [ 25 post ]  Go to page: [1] [2]

 Relevant Pages 

1. free pascal vs turbo pascal - range checking

2. GNU Pascal - no range checks?

3. Turbo Pascal vs ANSI Pascal

4. THINK PASCAL VS TURBO PASCAL.

5. Borland Turbo Pascal vs Pascal with Objects

6. Turbo Pascal 7.0 vs Borland Pascal 7.0

7. Error 201 - Range checking error with Turbo Database ToolBox - Win 1.5

8. Turbo Pascal 7.0 vs Turbo C++ 3.1

9. Turbo Power's Turbo Professional and Free Pascal

10. Turbo Power's Turbo Professional and Free Pascal

11. Free Pascal Bounds Check Error

12. Free VS Turbo (speed)

 

 
Powered by phpBB® Forum Software