[OT] Some neat ideas from the Kotlin language
rsw0x via Digitalmars-d
digitalmars-d at puremagic.com
Mon Feb 22 23:18:09 PST 2016
On Tuesday, 23 February 2016 at 06:49:46 UTC, Tobias Müller wrote:
> rsw0x <anonymous at anonymous.com> wrote:
>> On Saturday, 20 February 2016 at 09:40:40 UTC, Tobias Müller
>> wrote:
>>> [...]
>>
>> D has this too, but only for nullable types afaik.
>>
>> if(byte* ptr = someFunc()){
>> //...
>> }
>>
>>
>
> That's not quite the same as there are no non-nullable pointers
> in D.
> There's no guarantee from the type system that the byte* is not
> null and
> there are no compiler checks involved.
> It's a simple runtime check.
>
> OTOH in the examples in Kotlin/Rust the variable 'var' changes
> its type
> from 'int?' to plain 'int'.
> In Kotlin this is done with static analysis, in Rust with
> rebinding of the
> name.
>
> Tobi
Rust's Option<T> checks are not done at compile-time in most
cases unless something changed drastically in the past ~18 months.
More information about the Digitalmars-d
mailing list