I'd like to know, too. Seems a very weird request to me, unless I'm missing something that makes it essential.langinagel wrote:what is the advantage to use the very same name of a variable in a certain block?
Protected Variables w/in a block.
-
- Addict
- Posts: 1482
- Joined: Tue Feb 22, 2011 1:16 pm
Re: Protected Variables w/in a block.
Microsoft Visual Basic only lasted 7 short years: 1991 to 1998.
PureBasic: Born in 1998 and still going strong to this very day!
PureBasic: Born in 1998 and still going strong to this very day!
Re: Protected Variables w/in a block.
Well, most of the features are not essential, even Assembly provides way more features
than the bare minimum. It's not about that, it's about giving the programmers more
possibilities to write better code (in terms of readability, maintainability, ...).
On of the reason for scoping is information hiding, being able to define scope local variables
ensures consistency within that scope (no access from outside).
Of course this feature has a much larger effect on module / class scope or even file scope,
PB doesn't support any of those yet.
There is no downside if scopes are supported, none whatsoever. It only has advantages
and makes it easier to write well structured code. If certain people don't care about that,
well...
than the bare minimum. It's not about that, it's about giving the programmers more
possibilities to write better code (in terms of readability, maintainability, ...).
On of the reason for scoping is information hiding, being able to define scope local variables
ensures consistency within that scope (no access from outside).
Of course this feature has a much larger effect on module / class scope or even file scope,
PB doesn't support any of those yet.
There is no downside if scopes are supported, none whatsoever. It only has advantages
and makes it easier to write well structured code. If certain people don't care about that,
well...
Blog: Why Does It Suck? (http://whydoesitsuck.com/)
"You can disagree with me as much as you want, but during this talk, by definition, anybody who disagrees is stupid and ugly."
- Linus Torvalds
-
- Addict
- Posts: 4779
- Joined: Thu Jun 07, 2007 3:25 pm
- Location: Berlin, Germany
Re: Protected Variables w/in a block.
The problem seems to be here, that there is no general agreement in this regard.Shield wrote:There is no downside if scopes are supported, none whatsoever. It only has advantages
and makes it easier to write well structured code.

E.g.
langinagel wrote:From my point of view it decreases readability and the proper understanding of the code.
Re: Protected Variables w/in a block.
Yes and for some people procedures make the code less readable so they use gosub / goto...
A lot of times people cannot appreciate certain things (classes, modules, type safety, and what not...)
because they don't know how to use them properly or never applied those principles before to be
able to correctly judge them.
I'm not pointing fingers here and frankly I don't really care if PB ever gets those features.
It would be nice for me and for a lot of other guys to see some of the "modern" features
implemented in PB. It's just suggestions that would bring PB a little further ahead.
Of course PB is PB, but there is a reason a vast majority of the most popular languages share
a common set of features: because they work and because they are worth it.
A lot of times people cannot appreciate certain things (classes, modules, type safety, and what not...)
because they don't know how to use them properly or never applied those principles before to be
able to correctly judge them.
I'm not pointing fingers here and frankly I don't really care if PB ever gets those features.
It would be nice for me and for a lot of other guys to see some of the "modern" features
implemented in PB. It's just suggestions that would bring PB a little further ahead.
Of course PB is PB, but there is a reason a vast majority of the most popular languages share
a common set of features: because they work and because they are worth it.
Blog: Why Does It Suck? (http://whydoesitsuck.com/)
"You can disagree with me as much as you want, but during this talk, by definition, anybody who disagrees is stupid and ugly."
- Linus Torvalds
-
- Addict
- Posts: 1482
- Joined: Tue Feb 22, 2011 1:16 pm
Re: Protected Variables w/in a block.
How can protecting a variable inside an If/Then block, and also using the same unprotected variable name outside of that block, be of any practical use? I don't get it. Please show me a practical example (with pseudo-code if necessary) of what it can bring to the table, because my mind obviously can't conceive of the use. 

Microsoft Visual Basic only lasted 7 short years: 1991 to 1998.
PureBasic: Born in 1998 and still going strong to this very day!
PureBasic: Born in 1998 and still going strong to this very day!
Re: Protected Variables w/in a block.
For me the major advantage lays in loops, especially 'for' loops,
where I don't want to have the counter variable outside of the loop.
It's also useful for other loops to contain the state completely on
the inside.
Other languages offer closures (basically sub function inside another function that has access to outside variables).
That's another reason why I want to make sure that only a few required variables are visible.
I do agree this is not the *most* useful feature, however it is very useful on module level.
where I don't want to have the counter variable outside of the loop.
It's also useful for other loops to contain the state completely on
the inside.
Other languages offer closures (basically sub function inside another function that has access to outside variables).
That's another reason why I want to make sure that only a few required variables are visible.
I do agree this is not the *most* useful feature, however it is very useful on module level.
Blog: Why Does It Suck? (http://whydoesitsuck.com/)
"You can disagree with me as much as you want, but during this talk, by definition, anybody who disagrees is stupid and ugly."
- Linus Torvalds
-
- Addict
- Posts: 4779
- Joined: Thu Jun 07, 2007 3:25 pm
- Location: Berlin, Germany
Re: Protected Variables w/in a block.
Yes, in your opinion. In other people's opinion it would not do so. And claiming that all those people just don't know how to use the proposed feature properly or some such is not based on facts.Shield wrote:It's just suggestions that would bring PB a little further ahead.
Re: Protected Variables w/in a block.
I'm not claiming anything, this is just the first obvious thought that pops into my mind
after reading some posts here and there on different forums.
after reading some posts here and there on different forums.

Blog: Why Does It Suck? (http://whydoesitsuck.com/)
"You can disagree with me as much as you want, but during this talk, by definition, anybody who disagrees is stupid and ugly."
- Linus Torvalds
-
- Addict
- Posts: 1482
- Joined: Tue Feb 22, 2011 1:16 pm
Re: Protected Variables w/in a block.
[Never mind]
Last edited by MachineCode on Tue May 21, 2013 10:50 am, edited 1 time in total.
Microsoft Visual Basic only lasted 7 short years: 1991 to 1998.
PureBasic: Born in 1998 and still going strong to this very day!
PureBasic: Born in 1998 and still going strong to this very day!
-
- Addict
- Posts: 4779
- Joined: Thu Jun 07, 2007 3:25 pm
- Location: Berlin, Germany
Re: Protected Variables w/in a block.
OK, I see.Shield wrote:I'm not claiming anything, this is just the first obvious thought that pops into my mind
after reading some posts here and there on different forums.

Re: Protected Variables w/in a block.
Since this might have been understood the wrong way, let me clarify:
It's totally OK not to understand everything (heck, I don't understand anything)
and having an opinion and personal preferences is always good.
However, I noticed often on these forums that people tend to avoid new technologies,
features, ways of doing things, and so on, trying to stick to their old habits and sometimes
fighting furiously against anything that's new or different.
That's what I tried to point out here without explicit relation to this thread.
Nothing more. If that's right or wrong, each person here might judge this by himself / herself.
This is my opinion I dared to share here and anyone else can do so.
And now, back to the topic.
It's totally OK not to understand everything (heck, I don't understand anything)
and having an opinion and personal preferences is always good.
However, I noticed often on these forums that people tend to avoid new technologies,
features, ways of doing things, and so on, trying to stick to their old habits and sometimes
fighting furiously against anything that's new or different.
That's what I tried to point out here without explicit relation to this thread.
Nothing more. If that's right or wrong, each person here might judge this by himself / herself.
This is my opinion I dared to share here and anyone else can do so.

And now, back to the topic.

Blog: Why Does It Suck? (http://whydoesitsuck.com/)
"You can disagree with me as much as you want, but during this talk, by definition, anybody who disagrees is stupid and ugly."
- Linus Torvalds
Re: Protected Variables w/in a block.
Then don't use a feature --- if having a feature meant everyone had to use it; there would be very few features, since not everyone uses every feature... I don't use gosub, but I don't advocate getting rid of them. Local scoping is a fairly common feature; but that doesn't mean you have to use it...Little John wrote:Yes, in your opinion. In other people's opinion it would not do so. And claiming that all those people just don't know how to use the proposed feature properly or some such is not based on facts.Shield wrote:It's just suggestions that would bring PB a little further ahead.
-
- Addict
- Posts: 4779
- Joined: Thu Jun 07, 2007 3:25 pm
- Location: Berlin, Germany
Re: Protected Variables w/in a block.
jassing wrote:Then don't use a feature --- if having a feature meant everyone had to use it; there would be very few features, since not everyone uses every feature... I don't use gosub, but I don't advocate getting rid of them. Local scoping is a fairly common feature; but that doesn't mean you have to use it...Little John wrote:Yes, in your opinion. In other people's opinion it would not do so. And claiming that all those people just don't know how to use the proposed feature properly or some such is not based on facts.Shield wrote:It's just suggestions that would bring PB a little further ahead.

Sorry, I don't understand what you want to tell me.
I know that I don't have to use it, and I didn't say that I have to use it.
Re: Protected Variables w/in a block.
Just because you can't see the reason for it; doesn't mean it should be denied to those that can see the value in it.Little John wrote: I know that I don't have to use it, and I didn't say that I have to use it.
-
- Addict
- Posts: 4779
- Joined: Thu Jun 07, 2007 3:25 pm
- Location: Berlin, Germany
Re: Protected Variables w/in a block.
Oh, you believe that I can't see why some people want to get this feature. Interesting.jassing wrote:Just because you can't see the reason for it