#dbugfix Issue 16486 200$

jmh530 john.michael.hall at gmail.com
Fri Mar 30 13:49:51 UTC 2018


On Friday, 30 March 2018 at 06:11:22 UTC, 9il wrote:
> Hello,
>
> Bugfix for the Issue 16486 [1] (originally [2]) is required for 
> mir-algorithm types [3], [4].
>
> For example, packed triangular matrix can be represented as
>
> Slice!(Contiguous, [1], StairsIterator!(T*))
> Slice!(Contiguous, [1], 
> RetroIterator!(MapIterator!(StairsIterator!(RetroIterator!(T*)), retro)))
>
> They are used in mir-lapack [5]. The bug fix also required for 
> mir (Sparse, CompressedTensor), and for the future Dlang image 
> library.
>
> Workarounds aren't interesting.
>
> 200$  - bounty ( I can pay directly or transfer money to the 
> Dlang Foundation )
>
> Best Regards,
> Ilya Yaroshenko
>
> [1] https://issues.dlang.org/show_bug.cgi?id=16486
> [2] https://issues.dlang.org/show_bug.cgi?id=16465
> [3] 
> http://docs.algorithm.dlang.io/latest/mir_ndslice_slice.html#Slice
> [4] http://docs.algorithm.dlang.io/latest/mir_series.html#Series
> [5] 
> https://github.com/libmir/mir-lapack/blob/master/source/mir/lapack.d

Given the recent blog post on std.variant, it occurs to me that 
this enhancement would also make writing functions that take 
Option types much easier. I'm adopting some of the code from the 
blog post below:

import std.variant;

alias Null = typeof(null); //for convenience
alias Option(T) = Algebraic!(T, Null);

Option!size_t indexOf(int[] haystack, int needle) {
     foreach (size_t i, int n; haystack)
         if (n == needle)
             return Option!size_t(i);
     return Option!size_t(null);
}

auto foo(T)(VariantN!(T.sizeof, T, typeof(null)) x)
{
     return x;
}

auto bar(T : Option!U, U)(T x)
{
     return x;
}

auto baz(T)(Option!T x)
{
     return x;
}

void main()
{
     import std.stdio : writeln;

     int[] a = [4, 2, 210, 42, 7];
     Option!size_t index = a.indexOf(42);

     writeln(index.foo!size_t); //works
     //writeln(index.foo); //doesn't work
     //writeln(index.bar); //doesn't work
     //writeln(index.baz); //doesn't work
}


More information about the Digitalmars-d mailing list