EnableExplicit and For loops

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
User avatar
Tenaja
Addict
Addict
Posts: 1959
Joined: Tue Nov 09, 2010 10:15 pm

Re: EnableExplicit and For loops

Post by Tenaja »

Little John wrote:Just appending a type identifier such as .i to a variable name (without using Define, Global, Protected or Static) is currently not considered expilict declaration of a variable in PB. If your suggestion would be implemented in this way, it would change the meaning of EnableExplicit. That would cause unnecessary confusion.

Regards, Little John
I'm with LJ on this. Imagine being required to type this...

Code: Select all

Procedure Foo()
  For counter = 1 To 10
    protected.i counter
    Next
EndProcedure
And this is just a mess:

Code: Select all

Procedure Foo()
  scope
    protected.i counter
    For counter = 1 To 10
    Next
  endscope
EndProcedure
I think the challenge is that Fred did not structure the original language with this path in mind. The result is a system that works quite well, but is not well suited to a change in this direction. And yes, there has been a time or two where I would have used this feature, but in reality it does not add "much" to what PB has already. I'd rather he work on cross-compatibility or speed. (Or whatever the most popular request were in the poll...)
User avatar
Tenaja
Addict
Addict
Posts: 1959
Joined: Tue Nov 09, 2010 10:15 pm

Re: EnableExplicit and For loops

Post by Tenaja »

AHA! I have come up an alternative.

The big issue is the EnableExplicit requirement of using one of those keywords. In C, you are only required to use the var "type", such as int i, despite having many other modifiers available. Maybe if Fred added an intermediate EnableExplicitType (a "light" explicit, if you will) that only required the "type", then we could use this with impunity:

Code: Select all

Procedure Foo()
  For counter.i = 1 To 10
    Next
EndProcedure
I have always thought it weird that you could define a variable in so many ways...
1. just start using it
2. Use it with the appended type
3. Defining it with a keyword
And was never fond of 2 without 3.

And while this alternative is certainly viable, clean, and backward compatible, and even desireable, I still would rather he work on other stuff.
Little John
Addict
Addict
Posts: 4779
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Re: EnableExplicit and For loops

Post by Little John »

Tenaja wrote:
Little John wrote:Just appending a type identifier such as .i to a variable name (without using Define, Global, Protected or Static) is currently not considered expilict declaration of a variable in PB. If your suggestion would be implemented in this way, it would change the meaning of EnableExplicit. That would cause unnecessary confusion.

Regards, Little John
I'm with LJ on this.
But what you wrote is more or less the contrary of what I wrote ... :D
User avatar
Tenaja
Addict
Addict
Posts: 1959
Joined: Tue Nov 09, 2010 10:15 pm

Re: EnableExplicit and For loops

Post by Tenaja »

No, my original post ("I'm with LJ on this...") 100% agrees with what you said. The examples are an ugly mess, and changing the definition of EnableExplicit would be confusing--and worse, it would be problematic for backwards compatibility. Perhaps "Imagine being required to type this..." did not come across the language barrier, but it was a rhetorical statement showing an undesirable example. And if we are not now on the same page, then I still do not know what your point was.

The only thing I suggested that did not agree with you was in my second post, and that would be the possibility of adding a new directive that was EnableExplicitLight, or EnableExplicitType, and that suggestion does not contradict with anything you said--it merely adds an alternative.
User avatar
Tenaja
Addict
Addict
Posts: 1959
Joined: Tue Nov 09, 2010 10:15 pm

Re: EnableExplicit and For loops

Post by Tenaja »

Kukulkan wrote:I understand and can follow the argumentation of foz.

What about this syntax:

Code: Select all

Protected value
For Protected counter.b = 0 To 10
  value + counter
Next
The drawback is, that Protected is no longer a valid variable name (now a reserved keyword). Or is it already (I don't know)?

Kukulkan
This would work, and it would be backward compatible. It would also automatically give scope. This does have merits that Fred could consider.
Little John
Addict
Addict
Posts: 4779
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Re: EnableExplicit and For loops

Post by Little John »

@Tenaja:
I do not want you (or anyone else) to distort the meaning of my posts. My life time is limted, and after posting a message, I don't want to post three additional messages just in order to explain what I did not write in the other message. Shouldn't be too hard to understand. You are free to write what you want, but just let me alone :!:
User avatar
Tenaja
Addict
Addict
Posts: 1959
Joined: Tue Nov 09, 2010 10:15 pm

Re: EnableExplicit and For loops

Post by Tenaja »

Little John wrote:@Tenaja:
I do not want you (or anyone else) to distort the meaning of my posts. My life time is limted, and after posting a message, I don't want to post three additional messages just in order to explain what I did not write in the other message. Shouldn't be too hard to understand. You are free to write what you want, but just let me alone :!:
Ok, well, I apologize if I do not communicate clearly sometimes. The bottom line is that I agreed fully with your post that I quoted.
Post Reply