Why I could not cast string to int?
xancorreu
xancorreu at gmail.com
Fri Feb 3 06:38:45 PST 2012
Al 02/02/12 20:11, En/na Ali Çehreli ha escrit:
> On 02/02/2012 11:00 AM, xancorreu wrote:
> > Al 02/02/12 19:18, En/na bearophile ha escrit:
>
> > Can I say "serialize the first, second and third arguments as Class
> > Person"?
> >
> > I mean, if you define a class Person like:
> >
> > class Person {
> > string name
> > uint age
> > dead bool
> > }
> >
> > could you serialize the input from console, like
> > Std.in.serialize(Person, args(0), args(1), args(2))?
>
> I haven't used it but there is Orange:
>
> https://github.com/jacob-carlborg/orange
>
> I think it will be included in Phobos.
>
> > You could do that "manually" checking each paramm, but it's a
> tedious task.
>
> If the input is exactly in the format that a library like Orange
> expects, then it's easy.
>
> To me, constructing an object from user input is conceptually outside
> of OO, because there is no object at that point yet. It makes sense to
> me to read the input and then make an object from the input.
For my it could be put in a outside library, not in the class of the
object. And if it's well designed, it could be informed of all
exceptions....
>
> Depending on the design, the input may be rejected by the function
> that reads the input, by the constructor of the type, or by both.
>
> > Thanks,
> > Xan.
>
> Ali
>
More information about the Digitalmars-d-learn
mailing list