Ceylon language

bearophile bearophileHUGS at lycos.com
Wed Apr 13 10:06:24 PDT 2011


Kagamin:

> How will it work on this code?
> 
> String? name = process.args.first;
> myLibCustomEnforce(exists name);
> writeLine("Hello " name "!");

If you want to implement the feature well, then the compiler has to manage a bit of type state too. The state of the type of the (here immutable) variable "name" before myLibCustomEnforce() is different from the state of the type of "name" after that call.


>> shared class Character(Natural utf16)
>>     extends Object()
>>     satisfies Ordinal & Comparable<Character> {
>>         ...
>> }
>>
>> The syntax X&Y represents the intersection of two types. The syntax X|Y represents the union of two types.
>
> What does it mean?

Those Ordinal and Comparable<Character> seem interfaces, and each of them has a certain number of methods. If you use Ordinal | Comparable<Character> I persume the Character class must implement the methods of both interfaces (as in D), while with "&" you need to implement just the methods present in both interfaces. I don't have enough experience about this to tell how much useful this feature is. But it's not at the top of the things I look for.


> Haha, finally properly scoped switch statement, but it goes java too much. Braces are required?

Ceylon is meant to be a very regular and safe language designed for not expert programmers too, so I presume they are required here.

Bye,
bearophile


More information about the Digitalmars-d mailing list