Allow using module names with 'With' directive

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
User avatar
Blue
Addict
Addict
Posts: 964
Joined: Fri Oct 06, 2006 4:41 am
Location: Canada

Allow using module names with 'With' directive

Post by Blue »

It would be great to be able to make use of With/EndWith wirth module names.

example :

Code: Select all

DeclareModule Ferrari
    #moduleName = "Ferrari"
    Define units
EndDeclareModule

Module Ferrari
    units = FactoryOutput(12)
EndModule
..
..
With Ferrari
    Debug #moduleName
    Debug units
EndWith
..
..
The result would be, of course, the same we now have with the UseModule/UnuseModule construct.
But it would offer the advantage of a lighter, clearer style when coding just a few lines.

For longer coding sections, the UseModule/UnuseModule pair would remain available, and most likely preferable.
PB Forums : Proof positive that 2 heads (or more...) are better than one :idea:
c4s
Addict
Addict
Posts: 1981
Joined: Thu Nov 01, 2007 5:37 pm
Location: Germany

Re: Allow using module names with 'With' directive

Post by c4s »

Just for the reference: "With" Keyword for Modules... ;)


Edit:
By the way, using Use/UnuseModule isn't the same as naming conflicts can very likely occur when importing the whole module.
If any of you native English speakers have any suggestions for the above text, please let me know (via PM). Thanks!
User avatar
Blue
Addict
Addict
Posts: 964
Joined: Fri Oct 06, 2006 4:41 am
Location: Canada

Re: Allow using module names with 'With' directive

Post by Blue »

c4s wrote:Just for the reference: "With" Keyword for Modules... ;)
You caught me being too lazy to do even the most basic search before opening this topic. :oops:
I stand corrected.
PB Forums : Proof positive that 2 heads (or more...) are better than one :idea:
Post Reply