like types
bearophile
bearophileHUGS at lycos.com
Sun Aug 7 05:26:18 PDT 2011
Adam D. Ruppe Wrote:
> This seems to be to be nothing more than applying the same
> idea behind objects and interfaces to other types... if all
> variables were typed Object and you had:
>
> interface Int {}
> interface String {}
>
> void whatever(Int lineno, String rawdata) {}
>
> it'd be the same thing, would it not?
In their language (here adapted to D syntax) this compiles with no errors, and it gives an error at runtime in the first line of foo, because the dynamic type of x is string, and it's not like an int:
int foo(like int y) { return y + 1; }
void main() {
dyn x = "bar";
foo(x);
}
Is this the same thing you are saying?
Bye,
bearophile
More information about the Digitalmars-d
mailing list