[phobos] readf for the novice

Jesse Phillips jesse.k.phillips at gmail.com
Fri Aug 20 13:16:08 PDT 2010


There was a newsgroup post on this subject the beginning of this week
and it didn't get much feedback, other than a couple "sounds good to
me"

http://www.digitalmars.com/webnews/newsgroups.php?art_group=digitalmars.D&article_id=115470

I offered to clean up my implementation. There are some things I need
to experiment with and choose what would be best. And most importantly
I need to find out if it would be considered a good addition to
Phobos. The below code is an example of the functions and their usage:

import std.interact;

void main() {
    auto age = userInput!int("Please Enter you age");

    if(userInput!bool("Do you want to continue?"))
    {
        auto outputFolder = pathLocation("Where you do want to place
the output?");
        auto color = menu!string("What color would you like to use?",
["Blue", "Green"]);
    }

    auto num = require!(int, "a > 0 && a <= 10")("Enter a number from 1 to 10");
}

Opinions?

-- 
Liberty means responsibility. That is why most men dread it.
  - George Bernard Shaw


More information about the phobos mailing list