ceylon/ceylon-js — Issue #47: Derive ceylon.language.Boolean from JavaScript Boolean
Author: ikasiuk
Created: 2012-02-18 13:49:19+00:00
State: open
Labels: optimisation

I just pushed a change (17095f0444b9158097c02a6aa97c72659327a402) which modifies the implementation of ceylon.language.Boolean so that it is derived from JavaScript's Boolean and `getTrue`/`getFalse` just return `true`/`false`. Because JavaScript does autoboxing for primitive boolean values this means that the following should work:

```
var s = true.getString(); // "true"
var b = isOfType(false, 'ceylon.language.Boolean'); // true
var b2 = !(2==1).equals(true); // true
```

So Ceylon Booleans and JavaScript booleans are basically interchangeable. I kept the old code for now (commented out) but as far as I can see nothing has been broken. The idea is that this could allow us to simplify the JS code we write and generate.
What do you think? Am I missing something?

Doing the same for other types would be conceivable but probably more complicated. For instance, ceylon.language.String has methods (replace, split) that have identical names as methods of JavaScript's String class so it would be tricky to unify them.