digitalmars.D.learn - sameness
- sclytrack (18/18) Jan 20 2012 ---------------------------------------
- bearophile (5/8) Jan 20 2012 It's a Zen thing.
- sclytrack (13/30) Feb 02 2012 This means we can't create a Stride that would behave like a
---------------------------------------
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) {}
---------------------------------------
Jan 20 2012
sclytrack:letters are different yet the same ... letters are differentIt'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
Jan 20 2012
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.
Feb 02 2012









bearophile <bearophileHUGS lycos.com> 