Scope modules DIP rough messy draft.

luckoverthere luckoverthere at gmail.cm
Sat Oct 27 02:07:56 UTC 2018


On Saturday, 27 October 2018 at 00:20:33 UTC, 12345swordy wrote:
> https://github.com/12345swordy/DIPs/blob/Encapsulation/DIPs/DIPxxxx.md
> Yea, yea, I know it format wise it a giant mess, but I got 
> start somewhere don't I?

I don't know the rationale to me seems weak:

> Using D as a scripting language becomes more complicated to use 
> for one time scripts as you have to deal with multiple files if 
> you design the classes/structs to be encapsulated by 
> themselves. Where it would be idealy for the scripter to just 
> to handle one file instead of mutiple files.

Why do "one time scripts" need this feature? They will be used 
one time, no? Why do you need to follow encapsulation for a 
script you will run once? It will be small enough that you  can 
read all the code and know what it does.

> Porting from C++ to D involves refactoring, when the programmer 
> should be avoiding refactoring as much as possible during the 
> porting process, as refactoring during the port process can 
> lead to unintended bugs.

D is less restrictive than C++, because it is less restrictive 
you don't need to refactor. There also is no equivalent "friend" 
feature in D. Since you are just copying and pasting code, for 
the most part, where are you going to accidentally call a private 
function you weren't calling before in C++ that you are now going 
to call in D.

> Rapidly creating a program that involves multiple modules 
> requires multiple files for it, which can cause the slow down 
> the coding process, most noticeably in coding competition.

Again encapsulation is to aid in creation and maintenance of 
large code bases for longevity sake. Why would you be worried 
about encapsulation in a coding competition, most likely the 
fastest code aren't going to be following any sort of best 
practice as the fastest code will probably be using some crazy 
hacks anyways.

> It sometimes it easier to put every module in a single file for 
> a simple small program.

If it is a simple small program, then why require private at all? 
It's small enough that knowing what all the code does by a single 
person is reasonable, let alone that it doesnt do anything 
complicated either.


On a side note, "function" is a keyword in D. Not sure if that 
was an intentional choice or not, but seems odd with your 
examples and the syntax highlighting.




More information about the Digitalmars-d mailing list