Re: [fpc-pascal] Can variables be declared within a block?

2010-10-21 Thread Jürgen Hestermann

Rob Kennedy schrieb:
Write that into your local coding guidelines and 
enforce it in code reviews, not the language spec.


This argument can be used to promote each and every change, no matter how 
obscure it is.
But you forget that you may be forced to read code from other people in which case you are 
suddenly confronted with such weird constructs. Then it does not help that you had guidelines 
for your own code. I fail to see this as a relevant argument.


As I see it, Pascals success was just the simple (still powerful) syntax and 
semantic.
I would not like that this is given up by following trends and making Pascal 
the same thicket as C.
And for what reason? Just to save a little typing? I can't see how this 
outwheighs the disadvantage
of obscuring the code.


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


Re: [fpc-pascal] Can variables be declared within a block?

2010-10-20 Thread Reimar Grabowski
On Tue, 19 Oct 2010 21:18:03 +0100
Vannus  wrote:

> your example is at the start of a "for loop" block, which is much the same
> as having it at the start of a procedure block
So much the same that you can do it in pascal?
What about variables declared inside this for loop or inside the else block of 
an if statement.

> pascal prevents people from putting declarations strewn throughout the
> block, which i found reduces mistakes & bugs from 20-30 people coding, and
> their code is more readable. Coding standards are do similar thing.
You were talking about wrong code, not more readable code (which is very 
subjective in this case). So it looks like there is nothing wrong using this 
feature if it is available as you failed to show me that there is a problem. 
But it does not make much sense to discuss this here any further as it is not 
available in FPC.

R.
-- 
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing in e-mail?
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Can variables be declared within a block?

2010-10-19 Thread Vannus
On 19 October 2010 15:06, Rob Kennedy

> wrote:

> On Tue, Oct 19, 2010 at 12:23 AM, Jürgen Hestermann <
> juergen.hesterm...@gmx.de> wrote:
>
>> Reimar Grabowski schrieb:
>>
>>  for (int i = 0;...)
>>> Can't see anything wrong. I use declaration of variables inside blocks
>>> quite often in Java and C++ but have never missed it in pascal. Please
>>> enlighten me. What is so bad about creating temporary variables inside
>>> blocks instead of the beginning of a function in a language that supports
>>> it?
>>>
>>
your example is at the start of a "for loop" block, which is much the same
as having it at the start of a procedure block

pascal prevents people from putting declarations strewn throughout the
block, which i found reduces mistakes & bugs from 20-30 people coding, and
their code is more readable. Coding standards are do similar thing.

which of the three languages do you find fastest to code in, including any
debugging time?


>
>> I never thought about doing such declarations in Pascal.
>> Although I would not be against it in general (provided
>> that all identifiers have to be different)
>
>
> That seems like an arbitrary restriction, given that Object Pascal
> *already* allows multiple variables to have the same name *and* be declared
> somewhere other than the top of the function. Think of exception handlers. I
> don't know about everyone else, but my exception variables are all always
> named e.
>

are you sure? i've tried making var's in WITh and Try Except blocks using
Delphi7 with no luck. Or is this a difference between object pascal &
delphi?


>
> I could understand disallowing variables from *shadowing* other local
> variables of the same name (it's legal in C, but better compilers warn about
> it), but I see no reason for the language to require variables from
> different local scopes to have unique names. Write that into your local
> coding guidelines and enforce it in code reviews, not the language spec.
>
>
i'd agree with that, local vars are local after all. perhaps make it a
compiler option.

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

Re: [fpc-pascal] Can variables be declared within a block?

2010-10-19 Thread Rob Kennedy
On Tue, Oct 19, 2010 at 12:23 AM, Jürgen Hestermann <
juergen.hesterm...@gmx.de> wrote:

> Reimar Grabowski schrieb:
>
>  for (int i = 0;...)
>> Can't see anything wrong. I use declaration of variables inside blocks
>> quite often in Java and C++ but have never missed it in pascal. Please
>> enlighten me. What is so bad about creating temporary variables inside
>> blocks instead of the beginning of a function in a language that supports
>> it?
>>
>
> I never thought about doing such declarations in Pascal.
> Although I would not be against it in general (provided
> that all identifiers have to be different)


That seems like an arbitrary restriction, given that Object Pascal *already*
allows multiple variables to have the same name *and* be declared somewhere
other than the top of the function. Think of exception handlers. I don't
know about everyone else, but my exception variables are all always named e.

I could understand disallowing variables from *shadowing* other local
variables of the same name (it's legal in C, but better compilers warn about
it), but I see no reason for the language to require variables from
different local scopes to have unique names. Write that into your local
coding guidelines and enforce it in code reviews, not the language spec.


> I see one (small) disadvantage:
>
> If you want to know the number of bytes pushed to the stack
> (i.e. in a recursive function) then you don't have the declarations
> at one place anymore but they are spread over the code which would make it
> hard to get an overview.


Definitely small. It's already hard to do since you don't know how much
stack the compiler will allocate for temporary variables. (If the function's
small enough that you *can* predict the compiler's temporary usage, then
it's probably also small enough that you can count all the variable
declarations no matter where they appear.)

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

Re: [fpc-pascal] Can variables be declared within a block?

2010-10-19 Thread Sven Barth

Am 18.10.2010 20:21, schrieb Vannus:


On 18 October 2010 15:33, Sven Barth mailto:pascaldra...@googlemail.com>> wrote:

Am 18.10.2010 16:20, schrieb Michael Van Canneyt:

Object Pascal is a simple, beautiful and easy to read language.
The FPC
team tries to keep it that way.


And that is why I like the FPC team so much. :D


agreed.

When I went from C++ to Pascal back in 98/99, I found it quite hard
initially. Not being able to put variables anywhere & everywhere was
really awkward, but it dawned on me that I shouold be coding better.
Since then, i would say "If you need vars throughout your code, then
something is wrong with your code"


Makes you wonder why the ReactOS devs always declare their variables at 
the beginning of the functions (they're using C). :P Take a look at the 
source files of ntoskrnl for example.


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


Re: [fpc-pascal] Can variables be declared within a block?

2010-10-18 Thread Jürgen Hestermann

Reimar Grabowski schrieb:

for (int i = 0;...)
Can't see anything wrong. I use declaration of variables inside blocks quite often in Java and C++ 
but have never missed it in pascal. Please enlighten me. What is so bad about creating temporary variables 
inside blocks instead of the beginning of a function in a language that supports it?


I never thought about doing such declarations in Pascal.
Although I would not be against it in general (provided
that all identifiers have to be different) I see one
(small) disadvantage:

If you want to know the number of bytes pushed to the stack
(i.e. in a recursive function) then you don't have the declarations
at one place anymore but they are spread over the code which 
would make it hard to get an overview.

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


Re: [fpc-pascal] Can variables be declared within a block?

2010-10-18 Thread Jerry


On Oct 18, 2010, at 6:42 AM, Florian Klaempfl wrote:


Am 18.10.2010 14:58, schrieb Frank Church:
It's just a matter of readability, e.g. having a variable declared in
two blocks with the same name can cause you a lot of headache:


So don't allow identical names.

Ada allows exactly this feature (declaration within a block) and it is  
extremely simple and not the least confusing. It's also an easy and  
error-free way to manage dynamic memory allocation without using  
pointers.


Jerry



procedure p;

begin
 ...
 begin
   var i : integer;
   ...
   ...
   ...
   i:=12341234;
   ...
   ...
   ...
   ...
 end;
 ...
 ...
 ...
 begin
   var i : integer;
   ...
   writeln(i); <--- this i is not the same as above so i does not
contain 12341234 but it contains probably some garbage.
 end;


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


Re: [fpc-pascal] Can variables be declared within a block?

2010-10-18 Thread Andreas Berger



But it should make you wonder why this is no longer allowed in the
latest C++ standards.

What do you mean?

The current C++ standard (ISO 1998+TR1) permits short scope
declarations.  Indeed, C++ permits declarations to appear anywhere, not
just after a { to open a function or compound statement.  It has done
since the A.R.M. days, and in some implementations before that.
You are correct. Been a while since I programmed in C++. The new 
standard enforces that the short scope variable declared in a for loop 
goes out of scope at the end of the loop. Older implementations did not 
always enforce this. My bad.


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


Re: [fpc-pascal] Can variables be declared within a block?

2010-10-18 Thread David W Noon
On Mon, 18 Oct 2010 19:46:04 -0200, Andreas Berger wrote about Re:
[fpc-pascal] Can variables be declared within a block?:

> 
> > for (int i = 0;...)
> > Can't see anything wrong. I use declaration of variables inside
> > blocks quite often in Java and C++ but have never missed it in
> > pascal. Please enlighten me. What is so bad about creating
> > temporary variables inside blocks instead of the beginning of a
> > function in a language that supports it?
> >
> > R.
> But it should make you wonder why this is no longer allowed in the 
> latest C++ standards.

What do you mean?

The current C++ standard (ISO 1998+TR1) permits short scope
declarations.  Indeed, C++ permits declarations to appear anywhere, not
just after a { to open a function or compound statement.  It has done
since the A.R.M. days, and in some implementations before that.
-- 
Regards,

Dave  [RLU #314465]
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
david.w.n...@ntlworld.com (David W Noon)
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*


signature.asc
Description: PGP signature
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Can variables be declared within a block?

2010-10-18 Thread Andreas Berger



for (int i = 0;...)
Can't see anything wrong. I use declaration of variables inside blocks quite 
often in Java and C++ but have never missed it in pascal. Please enlighten me. 
What is so bad about creating temporary variables inside blocks instead of the 
beginning of a function in a language that supports it?

R.
But it should make you wonder why this is no longer allowed in the 
latest C++ standards.


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


Re: [fpc-pascal] Can variables be declared within a block?

2010-10-18 Thread Reimar Grabowski
On Mon, 18 Oct 2010 19:21:57 +0100
Vannus  wrote:

> Since then, i would say "If you need vars throughout your code, then
> something is wrong with your code"
for (int i = 0;...)
Can't see anything wrong. I use declaration of variables inside blocks quite 
often in Java and C++ but have never missed it in pascal. Please enlighten me. 
What is so bad about creating temporary variables inside blocks instead of the 
beginning of a function in a language that supports it?

R.
-- 
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing in e-mail?
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Can variables be declared within a block?

2010-10-18 Thread Vannus
On 18 October 2010 15:33, Sven Barth  wrote:

> Am 18.10.2010 16:20, schrieb Michael Van Canneyt:
>
>  Object Pascal is a simple, beautiful and easy to read language. The FPC
>> team tries to keep it that way.
>>
>
> And that is why I like the FPC team so much. :D
>
>
agreed.

When I went from C++ to Pascal back in 98/99, I found it quite hard
initially. Not being able to put variables anywhere & everywhere was really
awkward, but it dawned on me that I shouold be coding better.
Since then, i would say "If you need vars throughout your code, then
something is wrong with your code"

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

Re: [fpc-pascal] Can variables be declared within a block?

2010-10-18 Thread David W Noon
On Mon, 18 Oct 2010 15:42:31 +0200, Florian Klaempfl wrote about Re:
[fpc-pascal] Can variables be declared within a block?:

[snip]
> It's just a matter of readability, e.g. having a variable declared in
> two blocks with the same name can cause you a lot of headache:
> 
> procedure p;
> 
> begin
>   ...
>   begin
> var i : integer;
> ...
> ...
> ...
> i:=12341234;
> ...
> ...
> ...
> ...
>   end;
>   ...
>   ...
>   ...
>   begin
> var i : integer;
> ...
> writeln(i); <--- this i is not the same as above so i does not
> contain 12341234 but it contains probably some garbage.
>   end;

This was not usually a problem in ALGOL 60/68, PL/I or C/C++ -- these
languages have supported short scopes for up to 50 years -- as the
programmer was required to be aware of the different scopes of the
like-named variables.

I still use short scoped variables today, usually in C or C++.  I have
never had any such problems, even going back almost 40 years when I
programmed in ALGOL 60.  All block structured languages require the
programmer to understand the scope of all variables.

Indeed, short scopes can often circumvent name collisions, e.g.

 long some_func(unsigned long arg_1)
 {
long i;  /* procedure/function scoped */
unsigned max_iters;
. . .
/* calculate "i", "max_iters" and any others */
. . .
for (unsigned i = 0; i < max_iters; ++i) /* short scope "i" */
{
   /* "i" here is distinct from the one at function scope. */
   . . .
}
. . .
return i; /* back to procedure scoped "i". */
 }

Whether it is wise to use such lax naming of variables is open to
debate, but at least C and C++ allow the above.

That said, short scoping was never a part of original Pascal.  I think
Jensen & Wirth omitted it because it made the compiler simpler.
-- 
Regards,

Dave  [RLU #314465]
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
david.w.n...@ntlworld.com (David W Noon)
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*


signature.asc
Description: PGP signature
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Can variables be declared within a block?

2010-10-18 Thread Sven Barth

Am 18.10.2010 16:20, schrieb Michael Van Canneyt:

Object Pascal is a simple, beautiful and easy to read language. The FPC
team tries to keep it that way.


And that is why I like the FPC team so much. :D

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


Re: [fpc-pascal] Can variables be declared within a block?

2010-10-18 Thread Benedikt Schindler

> 
> I just want to create shorter variables like
> si :=  StringList.NameOfIndex(TableName.FieldByName('').AsString);
> ae := xxx;
> so:= yyy
> 
> to express complicated logic with them.
> 
> When I put them all at the top of the procedure, they are extra
> noise, which is not necessary for the understanding the purpose at
> the top level of the procedure.

I don't see the great extra noise of a

procedure SomeProc([someVars : Type]);
var
  [somevars : type;]
  si,ae,so : double; // temp vars for easy math;
begin
  [...]
end;

and i think the easy answer is:

No you could't, because in pascal you have to declare the vars in the
beginning of a procedure.

or:

No because this is pascal and not C

or:

why couldn't i use spanish in my english? :) *just kidding*


have all a nice day.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Can variables be declared within a block?

2010-10-18 Thread Michael Van Canneyt



On Mon, 18 Oct 2010, Bernd Kreuss wrote:


On 18.10.2010 15:55, Frank Church wrote:


I understand the need to avoid stuff that could create unintended errors


It would create something that I would call "irregularity" (or even
ugliness) in the language grammar. Nowhere else is it ever allowed to
have certain things inside a begin/end block, type, const, var are all
only allowed in the *same* certain places outside of such blocks.
Allowing var would also raise the question why not also allow type and
const and this would open a can of worms. It would destroy some (much)
of the simplicity (regularity, strictness, beauty, I don't know a better
word) of the grammar.


My thoughts exactly.

Object Pascal is a simple, beautiful and easy to read language. 
The FPC team tries to keep it that way.


If someone needs convincing that this is actually a plus: 
go and (try to) read and understand any moderately complicated perl program. 
Latex2html is a nice start :-)


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


Re: [fpc-pascal] Can variables be declared within a block?

2010-10-18 Thread Bernd Kreuss
On 18.10.2010 15:55, Frank Church wrote:

> I understand the need to avoid stuff that could create unintended errors

It would create something that I would call "irregularity" (or even
ugliness) in the language grammar. Nowhere else is it ever allowed to
have certain things inside a begin/end block, type, const, var are all
only allowed in the *same* certain places outside of such blocks.
Allowing var would also raise the question why not also allow type and
const and this would open a can of worms. It would destroy some (much)
of the simplicity (regularity, strictness, beauty, I don't know a better
word) of the grammar.

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


Re: [fpc-pascal] Can variables be declared within a block?

2010-10-18 Thread Bernd Kreuss
On 18.10.2010 15:55, Frank Church wrote:

> I just want to create shorter variables like
> si :=  StringList.NameOfIndex(TableName.FieldByName('').AsString);
> ae := xxx;
> so:= yyy
> 
> to express complicated logic with them.

Maybe the usage of WITH could be helpful in some of these cases

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


Re: [fpc-pascal] Can variables be declared within a block?

2010-10-18 Thread Frank Church
On 18 October 2010 14:55, Frank Church  wrote:

>
>
> On 18 October 2010 14:42, Florian Klaempfl  wrote:
>
>> Am 18.10.2010 14:58, schrieb Frank Church:
>> >
>> >
>> > On 18 October 2010 07:49, Florian Klaempfl > > > wrote:
>> >
>> > Am 18.10.2010 08:17, schrieb Zaher Dirkey:
>> > >
>> > >
>> > > On Thu, Oct 14, 2010 at 11:21 AM, Michael Van Canneyt
>> > > mailto:mich...@freepascal.org>
>> > >>
>> wrote:
>> > >
>> > >
>> > >
>> > > On Thu, 14 Oct 2010, Frank Church wrote:
>> > >
>> > > Can variables be declared within a begin end block?
>> > >
>> > >
>> > > No.
>> > >
>> >
>> >
>> > That is a rather emphatic no :).
>> >  Is there some performance or other related reason why it is a bad idea?
>>
>> It's just a matter of readability, e.g. having a variable declared in
>> two blocks with the same name can cause you a lot of headache:
>>
>> procedure p;
>>
>> begin
>>  ...
>>  begin
>>var i : integer;
>>...
>>...
>>...
>>i:=12341234;
>>...
>>...
>>...
>>...
>>  end;
>>  ...
>>  ...
>>  ...
>>  begin
>>var i : integer;
>>...
>>writeln(i); <--- this i is not the same as above so i does not
>> contain 12341234 but it contains probably some garbage.
>>  end;
>>
>
>
> My need is not for such kind or variables - it is for something like this.
>
> say I have some thing like:
>  StringList.NameOfIndex(TableName.FieldByName('').AsString) >
> AnotherEqualLongExpression + SomeOtherEvenLongerExpression.
>
> I just want to create shorter variables like
> si :=  StringList.NameOfIndex(TableName.FieldByName('').AsString);
> ae := xxx;
> so:= yyy
>
> to express complicated logic with them.
>
> When I put them all at the top of the procedure, they are extra noise,
> which is not necessary for the understanding the purpose at the top level of
> the procedure.
>
> I understand the need to avoid stuff that could create unintended errors
> and have experienced such issues before. I will be careful not to use the
> more than enough rope I have been given to hang myself. I promise :)
>
>

I sometimes use nested procedures for such purposes when it comes to the
program logic itself, having something like that for variables would be
nice.

PS. The promise above should be "we promise" :)


> ___
>> fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
>> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
>>
>
>
>
> --
> Frank Church
>
> ===
> http://devblog.brahmancreations.com
>



-- 
Frank Church

===
http://devblog.brahmancreations.com
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Can variables be declared within a block?

2010-10-18 Thread Frank Church
On 18 October 2010 14:42, Florian Klaempfl  wrote:

> Am 18.10.2010 14:58, schrieb Frank Church:
> >
> >
> > On 18 October 2010 07:49, Florian Klaempfl  > > wrote:
> >
> > Am 18.10.2010 08:17, schrieb Zaher Dirkey:
> > >
> > >
> > > On Thu, Oct 14, 2010 at 11:21 AM, Michael Van Canneyt
> > > mailto:mich...@freepascal.org>
> > >>
> wrote:
> > >
> > >
> > >
> > > On Thu, 14 Oct 2010, Frank Church wrote:
> > >
> > > Can variables be declared within a begin end block?
> > >
> > >
> > > No.
> > >
> >
> >
> > That is a rather emphatic no :).
> >  Is there some performance or other related reason why it is a bad idea?
>
> It's just a matter of readability, e.g. having a variable declared in
> two blocks with the same name can cause you a lot of headache:
>
> procedure p;
>
> begin
>  ...
>  begin
>var i : integer;
>...
>...
>...
>i:=12341234;
>...
>...
>...
>...
>  end;
>  ...
>  ...
>  ...
>  begin
>var i : integer;
>...
>writeln(i); <--- this i is not the same as above so i does not
> contain 12341234 but it contains probably some garbage.
>  end;
>


My need is not for such kind or variables - it is for something like this.

say I have some thing like:
 StringList.NameOfIndex(TableName.FieldByName('').AsString) >
AnotherEqualLongExpression + SomeOtherEvenLongerExpression.

I just want to create shorter variables like
si :=  StringList.NameOfIndex(TableName.FieldByName('').AsString);
ae := xxx;
so:= yyy

to express complicated logic with them.

When I put them all at the top of the procedure, they are extra noise, which
is not necessary for the understanding the purpose at the top level of the
procedure.

I understand the need to avoid stuff that could create unintended errors and
have experienced such issues before. I will be careful not to use the more
than enough rope I have been given to hang myself. I promise :)


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



-- 
Frank Church

===
http://devblog.brahmancreations.com
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Can variables be declared within a block?

2010-10-18 Thread Florian Klaempfl
Am 18.10.2010 14:58, schrieb Frank Church:
> 
> 
> On 18 October 2010 07:49, Florian Klaempfl  > wrote:
> 
> Am 18.10.2010 08:17, schrieb Zaher Dirkey:
> >
> >
> > On Thu, Oct 14, 2010 at 11:21 AM, Michael Van Canneyt
> > mailto:mich...@freepascal.org>
> >> wrote:
> >
> >
> >
> > On Thu, 14 Oct 2010, Frank Church wrote:
> >
> > Can variables be declared within a begin end block?
> >
> >
> > No.
> >
> 
> 
> That is a rather emphatic no :).
>  Is there some performance or other related reason why it is a bad idea?

It's just a matter of readability, e.g. having a variable declared in
two blocks with the same name can cause you a lot of headache:

procedure p;

begin
  ...
  begin
var i : integer;
...
...
...
i:=12341234;
...
...
...
...
  end;
  ...
  ...
  ...
  begin
var i : integer;
...
writeln(i); <--- this i is not the same as above so i does not
contain 12341234 but it contains probably some garbage.
  end;
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Can variables be declared within a block?

2010-10-18 Thread Frank Church
On 18 October 2010 07:49, Florian Klaempfl  wrote:

> Am 18.10.2010 08:17, schrieb Zaher Dirkey:
> >
> >
> > On Thu, Oct 14, 2010 at 11:21 AM, Michael Van Canneyt
> > mailto:mich...@freepascal.org>> wrote:
> >
> >
> >
> > On Thu, 14 Oct 2010, Frank Church wrote:
> >
> > Can variables be declared within a begin end block?
> >
> >
> > No.
> >
>

That is a rather emphatic no :).
 Is there some performance or other related reason why it is a bad idea? I'm
not knowledgeable in this area but I'd like to know.

Sometimes my variable declarations is filled with lots of variables for the
sake of making code involving long derived expressions comprehensible and
the clutter the understanding at the top level of the procedure.

Can a procedure be declared inline just for the sake of introducing those
variables?



> >
> > That found in Gnu Pascal
> > Can we ask to be feature request?
> >
>
> No.
> ___
> fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
>



-- 
Frank Church

===
http://devblog.brahmancreations.com
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Can variables be declared within a block?

2010-10-17 Thread Florian Klaempfl
Am 18.10.2010 08:17, schrieb Zaher Dirkey:
> 
> 
> On Thu, Oct 14, 2010 at 11:21 AM, Michael Van Canneyt
> mailto:mich...@freepascal.org>> wrote:
> 
> 
> 
> On Thu, 14 Oct 2010, Frank Church wrote:
> 
> Can variables be declared within a begin end block?
> 
> 
> No.
> 
> 
> That found in Gnu Pascal
> Can we ask to be feature request?
> 

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


Re: [fpc-pascal] Can variables be declared within a block?

2010-10-17 Thread Zaher Dirkey
On Thu, Oct 14, 2010 at 11:21 AM, Michael Van Canneyt <
mich...@freepascal.org> wrote:

>
>
> On Thu, 14 Oct 2010, Frank Church wrote:
>
>  Can variables be declared within a begin end block?
>>
>
> No.
>

That found in Gnu Pascal
Can we ask to be feature request?

Thanks
-- 
Zaher Dirkey
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Can variables be declared within a block?

2010-10-14 Thread Michael Van Canneyt



On Thu, 14 Oct 2010, Frank Church wrote:


Can variables be declared within a begin end block?


No.

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


[fpc-pascal] Can variables be declared within a block?

2010-10-14 Thread Frank Church
Can variables be declared within a begin end block?
eg.
if y = xxx then
begin
  var xxx;
  var yyy;
end

There are there as shortnames for  long expressions

-- 
Frank Church

===
http://devblog.brahmancreations.com
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal