Re: What is the value for D to allow assign bool to char/dchar? For me, it must be an error.

2021-08-07 Thread jfondren via Digitalmars-d-learn

On Saturday, 7 August 2021 at 21:45:09 UTC, apz28 wrote:

void main()
{
dchar d;
d = false;
d = true;
char c;
c = false;
c = true;
}


true is 1 and false is 0. These are valid char and dchar values. 
Some people and languages are on board with this (like APL, 
quote: "Ken asked Wolfram why it was that in Mathematica 
propositions don’t have values 0 and 1 as in APL instead of True 
and False. Wolfram replied that he had no objections, but the 
Mathematica implementers were against it."), and some aren't.


```d
assert(2 == true+true);
assert('a' == "ab"[3 > 5]);
assert(2 == iota(5).map!"a>2".sum);
```


What is the value for D to allow assign bool to char/dchar? For me, it must be an error.

2021-08-07 Thread apz28 via Digitalmars-d-learn

void main()
{
dchar d;
d = false;
d = true;
char c;
c = false;
c = true;
}