Re: [fpc-pascal] Nesting

2010-09-13 Thread Dimitri Smits

- "Juha Manninen (gmail)"  schreef:

> A new Lazarus review :
> http://delphimax.wordpress.com/2010/09/13/freepascal-and-lazarus-success-or-
> failure/
> 
> has this comment about Lazarus source:
> ---
> Abundant use of the Exit() command instead of nesting code in
> If/then/else. It 
> has been proven (last time in Delphi Informant Magazine) that allowing
> a 
> method to nest itself out makes faster code. It is also easier to read
> and 
> study. Exit should of course be used (it must be used in many
> situations) but 
> prudently.
> ---
> 
> Does nesting really create faster code?

not really tested, but think about the following:
1) with nesting: 
you validate an expression on being true/false. According to the result, you 
jump over a return statement of over a jmp statement to the cleanup block. (if 
not optimized by compiler) So, you ALWAYS jump/call.
2) without nesting:
you validate an expression on being true/false. According to the result, you 
jump to the clean-up block. Otherwise you continue.

I haven't studied processors that intimately on their branch-prediction beyond 
the original Pentium (586), but there it could have 'significant' repercussions 
with pipeline-stalling resulting in a few clock-cycles extra for a jump 
statement (regardless if it was taken).

> 
> For readability I like the nesting style, except when there are very
> many such 
> tests in one function.

that is a matter of taste. I find the *overuse* of exit somewhat bad 
programming. It is not really clear in a function/procedure all the time during 
debugging "why this piece of code is never visited" when you have a few of 
those blocks above the said "tested" statement. A remnant of C-style 
programmers? Ofcourse there are cases where you need to use it, but in most 
cases it is about writing the correct control-statement.

kind regards,
Dimitri Smits
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] Nesting

2010-09-13 Thread Juha Manninen (gmail)
A new Lazarus review :
http://delphimax.wordpress.com/2010/09/13/freepascal-and-lazarus-success-or-
failure/

has this comment about Lazarus source:
---
Abundant use of the Exit() command instead of nesting code in If/then/else. It 
has been proven (last time in Delphi Informant Magazine) that allowing a 
method to nest itself out makes faster code. It is also easier to read and 
study. Exit should of course be used (it must be used in many situations) but 
prudently.
---

Does nesting really create faster code?

For readability I like the nesting style, except when there are very many such 
tests in one function.

Juha
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] How to download fpc242 rc1 (to test a possible bug)

2010-09-13 Thread Luiz Americo Pereira Camara

Marco van de Voort escreveu:

In our previous episode, Luiz Americo Pereira Camara said:
  

And it did compile with 2.4.0?
  

Yes. Also with 251



Hmm, I think I know what that is. A wrong merge that should have been
reverted.

http://bugs.freepascal.org/view.php?id=16121

I'll see if I can squeeze that in.

The 2.5.1 breakage is a different question though.
  

Sorry not being clear. 251 also works

Luiz
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal



Re: [fpc-pascal] Fw: Question mark?

2010-09-13 Thread Sven Barth

Am 12.09.2010 15:09, schrieb Luis Fernando Del Aguila Mejía:

Excuse my ignorance. But what is mantis?


The bug tracker of Free Pascal (and Lazarus). You can find it here: 
http://bugs.freepascal.org/


Regards,
Sven
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal