Brief question, is it possible to write this so that the "alias fn" here appears as the final argument?

auto my_func(alias fn)(string name, string description, auto otherthing)

The above seems to work, since the type of "fn" can vary and it gets called inside of "my_func", but from an ergonomics point I'd love to be able to put the function last and write it inline:

  my_func("name", "description", "otherthing", (x, y, z) {
    auto foo = 1;
    return foo + 2;
  })


Currently I am calling it like:

  auto some_func = (x, y, z) {
    auto foo = 1;
    return foo + 2;
  };

  my_func!some_func("name", "description", "otherthing");

Which is fine, it's just that from a readability perspective it doesn't really allow for writing the function inline and you need to declare it separately.

Not a huge deal, just learning and thought I would ask =)

Thank you!

Reply via email to