XIncludeFile "filename.pb" As ModX

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
User avatar
the.weavster
Addict
Addict
Posts: 1576
Joined: Thu Jul 03, 2003 6:53 pm
Location: England

XIncludeFile "filename.pb" As ModX

Post by the.weavster »

As an alternative to the verbosity of

Code: Select all

DeclareModule ModX
;...
EndDeclareModule

Module ModX
;...    
EndModule
How about:

Code: Select all

XIncludeFile "filename.pb" As ModX
And then a naming convention to determine which procedures/variables in filename.pb are public and which are private so it doesn't have to be explicitly stated.
User avatar
Bisonte
Addict
Addict
Posts: 1305
Joined: Tue Oct 09, 2007 2:15 am

Re: XIncludeFile "filename.pb" As ModX

Post by Bisonte »

I agree ;)

But there is one question :

If there is no DeclareModule/EndDeclareModule block... how the compiler knows what is private and public ?

Or have I misunderstood .... ?
PureBasic 6.21 (Windows x64) | Windows 11 Pro | AsRock B850 Steel Legend Wifi | R7 9800x3D | 64GB RAM | RTX 5080 | ThermaltakeView 270 TG ARGB | build by vannicom​​
English is not my native language... (I often use DeepL.)
User avatar
the.weavster
Addict
Addict
Posts: 1576
Joined: Thu Jul 03, 2003 6:53 pm
Location: England

Re: XIncludeFile "filename.pb" As ModX

Post by the.weavster »

Bisonte wrote:If there is no DeclareModule/EndDeclareModule block... how the compiler knows what is private and public ?
I suggested a naming convention. One possible option for example:

Code: Select all

Procedure MyPublicFunction()

EndProcedure

Procedure my_private_function()

EndProcedure
So if the compiler finds a procedure name starting with a lowercase letter then it's private otherwise it's public.

I hate having to bother with Declares :evil:
Mistrel
Addict
Addict
Posts: 3415
Joined: Sat Jun 30, 2007 8:04 pm

Re: XIncludeFile "filename.pb" As ModX

Post by Mistrel »

Conventions should not necessarily be standards. For example, I define my private functions with a preceding underscore.
freak
PureBasic Team
PureBasic Team
Posts: 5940
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Re: XIncludeFile "filename.pb" As ModX

Post by freak »

An explicit public interface and a clear separation between definition & implementation encourage better information hiding which is the main purpose of modules. Usage of implicit conventions is rather counter productive in this regard.
quidquid Latine dictum sit altum videtur
Post Reply