Getting the best out of the IDE when using Modules

Everything else that doesn't fall into one of the other PB categories.
User_Russian
Addict
Addict
Posts: 1520
Joined: Wed Nov 12, 2008 5:01 pm
Location: Russia

Getting the best out of the IDE when using Modules

Post by User_Russian »

I have a few questions by the blog. http://www.purebasic.fr/blog/?p=417
The entire Module/EndModule is best also written in a single file
If the module contains more than 10,000 lines of code (a few hundred procedures, many structures and constants), how it all put in one file? The same code will dump!

It is better to divide the module code into multiple files.
For example.

Code: Select all

; File with the code module declaration (contains DeclareModule / EndDeclareModule).
XIncludeFile #PB_Compiler_FilePath + "MyModule_Declare.pbi"

Module MyModule

EnableExplicit

; Announcement of all private Module objects (Variables, structures, macros, etc.).
XIncludeFile #PB_Compiler_FilePath + "MyModule_pObject.pbi"

; Various procedures module.
XIncludeFile #PB_Compiler_FilePath + "MyModule_Misc.pbi"

; The core module
XIncludeFile #PB_Compiler_FilePath + "MyModule_Core.pbi"

; Further all public procedures of the module.

Procedure Init(State)
  ; Code procedure 
EndProcedure

Procedure Config(*Info.ModuleConfig)
  ; Code procedure 
EndProcedure

; The other public procedures.

EndModule
But thus does not work absolutely autocompletion that is difficult to programming, given the the amount of code and the number of private objects in the module.
Why IDE can not analyze the file, including the directive XIncludeFile?
c4s
Addict
Addict
Posts: 1981
Joined: Thu Nov 01, 2007 5:37 pm
Location: Germany

Re: Getting the best out of the IDE when using Modules

Post by c4s »

User_Russian wrote:[...] If the module contains more than 10,000 lines of code (a few hundred procedures, many structures and constants), how it all put in one file? The same code will dump!

It is better to divide the module code into multiple files. [...]
No, in that case it's probably better to divide up the module in multiple modules.
If any of you native English speakers have any suggestions for the above text, please let me know (via PM). Thanks!
User_Russian
Addict
Addict
Posts: 1520
Joined: Wed Nov 12, 2008 5:01 pm
Location: Russia

Re: Getting the best out of the IDE when using Modules

Post by User_Russian »

c4s wrote:No, in that case it's probably better to divide up the module in multiple modules.
What could have been divided, but not all of the code can be divided into "black boxes" without unjustified complexity of the program.
PMV
Enthusiast
Enthusiast
Posts: 727
Joined: Sat Feb 24, 2007 3:15 pm
Location: Germany

Re: Getting the best out of the IDE when using Modules

Post by PMV »

If a problem is to complex, then splitt it in many small ones.
I would be killed if i would try to do something like that at work :lol:
If you think it is not possible, then you can do it that way as
freak has written in his blog-post: It is just a limit of the IDE
and will not force you to do it. That is the best solution, i think :)

PS: do i have mention that i don't believe it is not possible to
split the code? Maybe not easy but not impossible :mrgreen:
And btw. i will have a few problems, too. As i have seen, in my
project are a few really tricky dependences where they shouldn't.
Will get me to an equal problem as you have ... so i have to
redesign it a little bit. Stupid me! :x

MFG PMV
User avatar
luis
Addict
Addict
Posts: 3895
Joined: Wed Aug 31, 2005 11:09 pm
Location: Italy

Re: Getting the best out of the IDE when using Modules

Post by luis »

@UR

I agree with you, I'm using a module to wrap a big library divided in many includes, and I don't want to convert each one in a module. There would be no advantage in doing so.
About module autocomplete, I decided to simply name the public functions the usual old way using xxx_procname where xxx_ is the prefix unique to this module, and to keep the module's declaration loaded in the ide to have autocomplete for all the public procs/consts/structs etc.
So in the end the only useful feature I use in my current case is the ability to keep some code/contants/structures private and that's pretty nice, but I least i don't have to struggle with other problems/limitations (excluding a convoluted but minor one).
Moreover this is a lot simpler for the compiler/editor and already proved in the past betas, so the risk to encounter stopping bugs at this stage is very low.
"Have you tried turning it off and on again ?"
A little PureBasic review
User_Russian
Addict
Addict
Posts: 1520
Joined: Wed Nov 12, 2008 5:01 pm
Location: Russia

Re: Getting the best out of the IDE when using Modules

Post by User_Russian »

Only the interface module (announcement of public and private facilities) can take up to 1000 lines (not counting private procedures). Siting it in a single file simply impractical! It is difficult to continuously scrolls the text up and down the length to find the desired structure or a constant, or else add a new one.
If you split the code into multiple files, then the problem becomes simpler, but does not work autocompletion.
Why IDE can not find XIncludeFile, and scan the file?
User avatar
luis
Addict
Addict
Posts: 3895
Joined: Wed Aug 31, 2005 11:09 pm
Location: Italy

Re: Getting the best out of the IDE when using Modules

Post by luis »

User_Russian wrote: Why IDE can not find XIncludeFile, and scan the file?
Consider the opening of an included file using ctrl+click (or whatever I don't remember) already does not work if the include is not super plain i.e.:

includefile "filename.ext"

If you split the name in multiple concatenated strings, of if you use the form

IncludeFile #PB_Compiler_FilePath + "filename.ext"

to make it work properly relative to the current file path, the sequence above does not work.

So this should work at least before you can expect the includefile to be properly evalued in modules, if ever.
"Have you tried turning it off and on again ?"
A little PureBasic review
freak
PureBasic Team
PureBasic Team
Posts: 5940
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Re: Getting the best out of the IDE when using Modules

Post by freak »

There are a number of languages where one module/class is limited to a single source file. It doesn't seem to cause any problems there either. As I wrote in the blog post, we could have gone the same route and enforced these rules in the compiler as well. We chose not to do that to give you the freedom to organize your code as you like.

There have always been code constructs that the IDE couldn't parse. If you make heavy use of macros in your code you can bend the PB syntax in ways that no amount of lexical analysis can resolve. Remember: the IDE does not compile the code. It just tokenizes it and does its best to understand what is going on from there. The IDE tries to be as helpful as it can be, but if you hide your code from it, you are out of luck ;) Modules are no different in this respect.
User_Russian wrote:Why IDE can not find XIncludeFile, and scan the file?
Because it is not as simple as you probably think. Feel free to prove me wrong by writing an IDE that does a better job at it :P
quidquid Latine dictum sit altum videtur
User_Russian
Addict
Addict
Posts: 1520
Joined: Wed Nov 12, 2008 5:01 pm
Location: Russia

Re: Getting the best out of the IDE when using Modules

Post by User_Russian »

freak wrote:There are a number of languages where one module/class is limited to a single source file. It doesn't seem to cause any problems there either.
But in these languages, there is certainly inherit modules, and other similar tools.
If PB, supported inheritance modules, I would have shared one module at a few (one module in the file) and would gather into one by using inheritance.
But for this would not prevent, support for private modules (to a global scope are not visible are the modules that should not be accessible from outside).
freak wrote:
User_Russian wrote:Why IDE can not find XIncludeFile, and scan the file?
Because it is not as simple as you probably think. Feel free to prove me wrong by writing an IDE that does a better job at it :P
I think it is not difficult to find XIncludeFile and scan the file, like a bud, he is in the current source code.
freak
PureBasic Team
PureBasic Team
Posts: 5940
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Re: Getting the best out of the IDE when using Modules

Post by freak »

User_Russian wrote:I think it is not difficult to find XIncludeFile and scan the file, like a bud, he is in the current source code.
Then prove it.
quidquid Latine dictum sit altum videtur
User_Russian
Addict
Addict
Posts: 1520
Joined: Wed Nov 12, 2008 5:01 pm
Location: Russia

Re: Getting the best out of the IDE when using Modules

Post by User_Russian »

That prove?
That that the code can be found XIncludeFile or what?

If XIncludeFile found between Module and EndModule, it clearly points to the fact that the included file is part of the module.

You write what problems have arisen with the include files and can find a way to solve the problem.
freak
PureBasic Team
PureBasic Team
Posts: 5940
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Re: Getting the best out of the IDE when using Modules

Post by freak »

I thought so. Words are cheap my friend.
quidquid Latine dictum sit altum videtur
User_Russian
Addict
Addict
Posts: 1520
Joined: Wed Nov 12, 2008 5:01 pm
Location: Russia

Re: Getting the best out of the IDE when using Modules

Post by User_Russian »

What did you expect? So I wrote IDE one hour?
Do I have the source code PB IDE to try to modify them?

Now I can help, just advice.
I understand what you are doing is not a simple task and I respect your work.
But I can not understand how there was a problem when searching XIncludeFile in the source code and analyze the contents of a file?
freak
PureBasic Team
PureBasic Team
Posts: 5940
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Re: Getting the best out of the IDE when using Modules

Post by freak »

I don't need your advice, and i don't have to explain myself to you. I told you how things are. Live with it or just don't use the IDE. Frankly, I don't care anymore.

I am fed up with people like you complaining why things are not the way you think they should be just because it sounds simple to do in your own head. Don't you think if there was a simple solution I would have done it? Just how incompetent do you think i am?
quidquid Latine dictum sit altum videtur
Locked