The D standard library is built on GC, is that a negative or positive?

Tejas notrealemail at gmail.com
Thu Dec 15 02:31:40 UTC 2022


On Wednesday, 14 December 2022 at 20:30:39 UTC, H. S. Teoh wrote:
> On Wed, Dec 14, 2022 at 07:38:51PM +0000, torhu via 
> Digitalmars-d wrote:
>> On Wednesday, 14 December 2022 at 01:47:29 UTC, Steven 
>> Schveighoffer wrote:
>> > 
>> > ```d
>> > void main() @nogc
>> > {
>> >    import std.conv;
>> >    auto v = "42".to!int;
>> > }
>> > ```
>> 
>> 
>> I have been wondering why there isn't a basic variation like 
>> this available:
>> 
>> ```d
>> auto i = "42".toOr!int(-1);
>> auto s = i.toOr!string(null);
>> ```
>
> This would be a nice addition to Phobos IMO.  Though we should 
> think of a better name for it. :-P
>
>
> T

Maybe we could've enhanced `to` itself had we named arguments in 
the language

```d
auto c = "42".to!int(error = <whatever value you want>);
```
Or maybe a `result` type would be enough, so no need for this?


More information about the Digitalmars-d mailing list