Proposal for custom time string formatting in std.datetime

zhang bitworld at qq.com
Sat Dec 24 19:05:37 PST 2011


> On Fri, 23 Dec 2011 02:21:37 -0000, Walter Bright  
> <newshound2 at digitalmars.com> wrote:
> 
> > On 12/22/2011 11:25 AM, Piotr Szturmaj wrote:
> >> I wish D could support partial modules - partial as analogy to C#'s  
> >> partial
> >> classes.
> >>
> >> module std.datetime-unit1;
> >> import std.datetime-unit2;
> >> // dash allowed only in submodules with the same module name
> >> ...
> >>
> >> module std.datetime-unit2;
> >> import std.datetime-unit1;
> >> ...
> >>
> >> // then
> >>
> >> module whatever;
> >> import std.datetime; // as usual
> >
> >
> > I have no idea why anyone would want this. (Is it because the file is  
> > too big to fit on a floppy disk? <g>)

As for big module, my solutions are:
1) put related modules into a package (or directory)
2) add a module named all.d into the directory, and this module will import all the other modules publicly
3) now just import the *all* module when needed

For example, we have these modules
	std\datetime\all.d
	std\datetime\unit1.d
	std\datetime\unit2.d
	std\datetime\unit3.d
in a package called std.datetime (a directory named std\datetime)

To import the datetime package, we use this:
	import std.datetime.all;

So, my suggestions are:
1) can we import the *all* module defaultly (maybe it called another module name) ?
   Then, we can use "import std.datetime;" instead of "import std.datetime.all;".
2) The compiler can recognise the importing module as a package, then import all modules in the package automaticly (including sub-package or not ?)
   Then, we just use "import std;" to import all the modules in the standard package.

> 
> It's of most benefit (IMO) for the Visual Studio IDE/GUI designer code.   
> The automated code generation goes into one source file, in a partial  
> class.  The user defined code into another source file/partial class.  It  
> makes life easier for both the developer and the GUI designer code itself.

Maybe this is another thing. The "partial class" seems important for auto-code-generation or function-extention.

----------
Zhang <bitworld at qq.com>



More information about the Digitalmars-d mailing list