June 22, 2011 Re: readf with strings | ||||
---|---|---|---|---|
| ||||
Posted in reply to Ali Çehreli | Ali Çehreli: > "oku" means "read": > > // Read into an existing variable > double d; > oku("Please enter a double: ", &d); > > // Read and return a value > int i = oku!int("Please enter an int: "); I have a related enhancement request since lot of time: http://d.puremagic.com/issues/show_bug.cgi?id=4716 Bye, bearophile |
June 23, 2011 Re: readf with strings | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile | > I have a related enhancement request since lot of time: http://d.puremagic.com/issues/show_bug.cgi?id=4716
>
> Bye,
> bearophile
>
That's exactly what I'd like to see. Voted.
After all, D is created with practicality in mind, and doing all that parsing is the opposite of what it's trying to achieve.
|
June 23, 2011 Re: readf with strings | ||||
---|---|---|---|---|
| ||||
Posted in reply to Dainius (GreatEmerald) | On 06/23/2011 02:27 AM, Dainius (GreatEmerald) wrote:
>> I have a related enhancement request since lot of time:
>> http://d.puremagic.com/issues/show_bug.cgi?id=4716
>>
>> Bye,
>> bearophile
>>
>
> That's exactly what I'd like to see. Voted.
>
> After all, D is created with practicality in mind, and doing all that
> parsing is the opposite of what it's trying to achieve.
The goal here is to have semantics for "Read an int from STDIN." I think the difficulty here is this really *should* be "Read a T from a stream." In C++, we have the stream operators ">>" and "<<". I really really really really miss these. I would love to have my stream operators back (and then implement the operators for classes and structs.) I think that "a = stdin.type_read!int();" or "std.type_read!int(&a);" would go a long way in getting there, as long as we could extend the template. I don't like the way python takes input from STDIN with raw_input() and input(). I'm not opposed to having a language support those semantics, but I would rather have a generic stream reader that does the conversion to a type for me that allows me to extend the conversion to include my own types.
|
Copyright © 1999-2021 by the D Language Foundation