Re: difficulty with rectangular arrays

2021-06-11 Thread Moth via Digitalmars-d-learn

On Friday, 11 June 2021 at 08:40:51 UTC, jfondren wrote:

The example in the spec is in a function body and you've copied
it to a class body, where the writeln() would also be in error.
I find quite hard to read
but I imagine there's a state/declaration distinction there, 

the code looking the same.

This works:

class Example {
double[6][3] matrix;
this() {
matrix = 0;

i see.
that's a bummer - i knew the `writeln()` wouldn't work in a class 
body, but i assumed that because other initializations work [e.g, 
`int myint = 4;` or `int[69] funny = 420;`], this case would be 
much the same. ah well.

off topic, your baba is you avatar is very cute.

difficulty with rectangular arrays

2021-06-11 Thread Moth via Digitalmars-d-learn

hullo all. i've encountered a bizzare inconsistency.

the following is the [D spec on rectangular 

void main()
import std.stdio: write, writeln, writef, writefln;
double[6][3] matrix = 0; // Sets all elements to 0.
writeln(matrix); // [[0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], 
[0, 0, 0, 0, 0, 0]]


however, when i attempt to place the very same code within a 

class ExampleClass
double[6][3] matrix = 0; //fails to compile - "Error: cannot 
implicitly convert expression `0` of type `int` to `double[6][3]`"


evidently i'm doing something wrong here, but i can't understand 
what or why. what's going on? have i misread the spec?

unicode characters are not printed correctly on the windows command line?

2019-12-21 Thread moth via Digitalmars-d-learn

hi all.

been learning d for the last few years but suddenly realised...

when i use this code:


the output displayed on the windows command line is "ÔÖÑ" [it 
works fine when piped directly into a text file, however].

i've looked about in this forum, but all that i could find was 
people in 2016[!] saying the codepage had to be altered - clearly 
nonsense, since Rust [which i am also learning] has no problem 
whatsoever displaying "♥".

is there any function i can call or setting i can adjust to get D 
to do the same, or do i have to wait for something to be fixed in 
the language / compiler itself?

best regards

moth []

Re: "lld-link: error: could not open libcmt.lib: no such file or directory"

2019-07-11 Thread moth via Digitalmars-d-learn
in case anyone else suffers from this in the future and is 
looking for a solution - redownloading visual studio 2017 and 
making sure the c++ workload was enabled fixed this for me. i'm 
not really sure why that worked, but i'm just happy to be able to 
learn again.

trans rights!
- moth

"lld-link: error: could not open libcmt.lib: no such file or directory"

2019-07-10 Thread moth via Digitalmars-d-learn

hi all!

after a long while away, i thought i'd download the latest D 
release and give learning it another shot. unfortunately, it 
looks like i screwed up somewhere big time =[

it was working fine for me before [a few months ago i think], but 
now whenever i try to compile i get the message "lld-link: error: 
could not open libcmt.lib: no such file or directory". sometimes, 
depending on what i'm trying to compile, it complains it can't 
find "OLDNAMES.lib" as well.

i thought it was just that i had installed D wrong at first, but 
i've uninstalled / reinstalled a dozen times now and it's still 
not working.

could i really have deleted whatever it's looking for somehow? i 
really want to be able to program in D, but i'm at my wit's end...

please help! =[
- moth

Check Instance of Template for Parameter Type/Value

2015-10-19 Thread Stewart Moth via Digitalmars-d-learn
I'm working with a library that has template structs of 
mathematical vectors that can sometimes be the type of an array 
I'm passing to a function.

The definition of the struct is like this:

struct Vector(type, int dimension_){ ... }

Where type is going to be an int/float/etc and dimension_ is 

I could write a bunch of functions for each case, but I'd rather 
not... I'd like to use something like the following:

void foo(T)(Array!T array){
if(isInstanceOf!(Vector, T)){
//get type of T or check it
//test if dimension_ is 2 or 3 or 4
} else {
//Non-vector stuff

But to do that I need to check that parameters of T as if it were 
an instantiated instance of Vector and I'm not sure how to 
accomplish that... Can anyone help me out with what I need to do?