On Monday, 11 July 2022 at 06:59:32 UTC, anonymouse wrote:
I did search for a better solution and came across...
https://tastyminerals.github.io/tasty-blog/dlang/2020/03/22/multidimensional_arrays_in_d.html
I like it!
It's been a good collaboration...
```d
import std.variant;
auto
On Monday, 11 July 2022 at 05:41:40 UTC, jfondren wrote:
Oh, sorry. I didn't defend the code in any way because I
assumed that the exceptional design would be seen as obviously
bad (and that someone else would dig harder in order to find a
better solution).
And you were right. I did search
On Sunday, 10 July 2022 at 19:14:34 UTC, Paul Backus wrote:
For reference, this is the more correct way:
```d
while (cast(TypeInfo_Array) v.type !is null) {
Variant elem = v[0];
// etc.
}
```
Hard to blame anyone for not coming up with that on their first
try, especially since
On Monday, 11 July 2022 at 03:17:33 UTC, anonymouse wrote:
On Sunday, 10 July 2022 at 18:31:46 UTC, drug007 wrote:
I'd like to say that using of exception to break loop is
really bad. Exception is exceptional thing but in the case
above the exception is ordinary completion of the loop
On Sunday, 10 July 2022 at 18:31:46 UTC, drug007 wrote:
I'd like to say that using of exception to break loop is really
bad. Exception is exceptional thing but in the case above the
exception is ordinary completion of the loop happens on regular
basis. Don't do that.
Thanks for the advice.
On Sunday, 10 July 2022 at 18:31:46 UTC, drug007 wrote:
On 7/10/22 20:26, anonymouse wrote:
On Sunday, 10 July 2022 at 06:26:37 UTC, jfondren wrote:
```d
import std.variant : Variant;
size_t[] shape(Variant v) {
import std.variant : VariantException;
size_t[] s;
try {
On Sunday, 10 July 2022 at 06:26:37 UTC, jfondren wrote:
```d
import std.variant : Variant;
size_t[] shape(Variant v) {
import std.variant : VariantException;
size_t[] s;
try {
while (true) {
Variant elem = v[0];
s ~= v.length;
v = elem;
On Saturday, 9 July 2022 at 23:04:20 UTC, anonymouse wrote:
On Saturday, 9 July 2022 at 14:46:36 UTC, Adam D Ruppe wrote:
Impossible; Variant's type is only known at runtime, and this
would require compile time knowledge.
Hmmm. Okay, thanks. What I really need to know is how many
On Saturday, 9 July 2022 at 14:46:36 UTC, Adam D Ruppe wrote:
Impossible; Variant's type is only known at runtime, and this
would require compile time knowledge.
Hmmm. Okay, thanks. What I really need to know is how many
dimensions an array has and the total elements per dimension so
that
On Saturday, 9 July 2022 at 14:36:44 UTC, anonymouse wrote:
auto vb = v.base; // what should I put here to achieve the
following:
typeof(vb); // int[][]
Impossible; Variant's type is only known at runtime, and this
would require compile time knowledge.
std.variant;
Variant v = [[1], [2], [3]];
writeln(v.type); // int[][]
typeof(v.type); // TypeInfo
assert(v.type == typeid(int[][]);
As demonstrated by the assert statement, .type returns the typeid
of the underlying type. How would I obtain the actual type such
that:
auto vb = v.base;
11 matches
Mail list logo