What's missing from Phobos for Orbit (package manager)

Marco Leise Marco.Leise at gmx.de
Wed Feb 13 00:34:36 PST 2013


Am Tue, 12 Feb 2013 13:38:53 +0100
schrieb Jacob Carlborg <doob at me.com>:

> I've compiled a list below of things used in Orbit (directly or 
> indirectly) that Phobos is lacking in. Please tell me if I'm wrong:

I can only tell you what of that list I would have had a use
for myself in the past:
 
>    * Configuration

Yes, native to the environment (e.g. use \AppData\Roaming on
Windows or .config on Linux)

> * ConfigMap -  Does not exist. An associative array with opDispatch 
> added to it. Allows to do things like:
> 
> auto config = ConfigMap();
> config.foo = "asd";
> config.bar.foo.baz = "foobar";
> 
> assert(config.foo == "asd");

I loaded an .INI template at CT (with default values and type
inference) and created nested structs from that. Was fun to do
in D. No matter what the implementation is, this is useful.

> * std.process - I have not used it myself but I've heard it's not optimal

The biggest shortcoming is that you cannot do IPC with it, as
it doesn't give you two-way pipes to the child process. Again,
that's useful and IIRC was in the std.process replacement.

> * std.getopt - Doesn't support the following:
>    * Required arguments
>    * Restricting the values of a given argument
>    * No way to automatically create a help/usage list out of the arguments
>    * Handling positional arguments
>    * No support for commands/action. That is "git commit", "commit" 
> would be the command/action
>    * Handle multiple command lines
>    * Validation of the arguments

All of that except "action" and "multiple command lines".
Validation is probably too complex to include at the spot. I
mean, sometimes you need to validate the combination of all
options, so you can just as well write a separate function.
 
> CTFE:

I think most of that exists in Phobos or can be constructed in
one line of code:

> * format - A simple formatting function

http://dlang.org/phobos/std_metastrings.html#.Format

> * indexOf

http://dlang.org/phobos/std_typetuple.html#.staticIndexOf

> * contains

staticIndexOf!(something, Tuple) != -1

> * fieldsOf - Returns all the fields of the given type

http://dlang.org/phobos/std_traits.html#.FieldTypeTuple

> * hasField - Returns true if the given type has the given field

staticIndexOf!(field, fieldsOf!Type) != -1

> * TypeOfField - Returns the type of a field
> * nameOfFieldAt - Returns the name of the field at the given position
> * set/getValueOfField - Sets/gets the value of a field

:( No idea... at least without mixins.

> * newInstance - Returns a new instance based on the class name or 
> ClassInfo. Can handle any class regardless of constructors

So I figure, Object.factory("ClassName") is too limited. I
used to just force my code work with that one.

-- 
Marco



More information about the Digitalmars-d mailing list