Thread overview | |||||
---|---|---|---|---|---|
|
January 20, 2012 sameness | ||||
---|---|---|---|---|
| ||||
--------------------------------------- letters are different yet the same immutable(char) [] letter1; const(char) [] letter2; char [] letter3; void proc1( const(char) [] letter) {} --------------------------------------- letters are different struct Container(T) { T letter; } Container!(const(char)) letter1; Container!(immutable(char)) letter2 Container!(char) letter3; void proc2(Container!(const(char)) letter) {} --------------------------------------- |
January 20, 2012 Re: sameness | ||||
---|---|---|---|---|
| ||||
Posted in reply to sclytrack | sclytrack:
> letters are different yet the same
> ...
> letters are different
It's a Zen thing.
Templates are very strict in the type you give them, while function arguments perform some silent type conversions. I think this will not change, because it's hard to design C++/D-style templates in a different way. In C++ happens something similar.
Bye,
bearophile
|
February 02, 2012 Re: sameness | ||||
---|---|---|---|---|
| ||||
Posted in reply to sclytrack | On 01/20/2012 01:18 PM, sclytrack wrote:
>
> ---------------------------------------
> letters are different yet the same
>
> immutable(char) [] letter1;
> const(char) [] letter2;
> char [] letter3;
>
> void proc1( const(char) [] letter) {}
>
> ---------------------------------------
> letters are different
>
> struct Container(T)
> {
> T letter;
> }
>
> Container!(const(char)) letter1;
> Container!(immutable(char)) letter2
> Container!(char) letter3;
>
> void proc2(Container!(const(char)) letter) {}
>
> ---------------------------------------
This means we can't create a Stride that would behave like a
built in type.
int stride a = new int stride(2,100);
const int stride b = a;
writeln(a.step);
a[10]++;
inout(int) hello(inout(int) stride a, inout(int) stride b) inout
{
}
I've also noticed something. There is a lot of casting in the inout.
5 degrees Celsius. These modern computers barely heat up the room.
|
Copyright © 1999-2021 by the D Language Foundation