Thanks for the explanation
On 12/20/2016 11:59 AM, somebody wrote:
I though D should have syntax similarities with C, but recently I've
found that array indexing in D is different. Suppose we have a code:
import std.stdio;
void main ()
{
wstring[6][2] strings;
strings[2][0] = "test";
}
It fails to compile becau
On Tuesday, 20 December 2016 at 19:59:41 UTC, somebody wrote:
I though D should have syntax similarities with C, but recently
I've found that array indexing in D is different. Suppose we
have a code:
import std.stdio;
void main ()
{
wstring[6][2] strings;
strings[2][0] = "test";
}
I
Thanks JKPdouble. I was hoping for a clear way to work
multidimensional arrays out.
On Sun, 28 Sep 2014 22:33:40 +0100
Stewart Gordon via Digitalmars-d-learn
wrote:
> You can do `new ubyte[256][256]`, if the destination type is a
> ubyte[256][]. The reason is that you are performing an allocation of
> the form `new T[n]`, which means allocate an array of n instances of
> type T
On Sun, 28 Sep 2014 07:40:23 -0700
"H. S. Teoh via Digitalmars-d-learn"
wrote:
> File a bug.
https://issues.dlang.org/show_bug.cgi?id=13556
signature.asc
Description: PGP signature
On 28/09/2014 08:48, ketmar via Digitalmars-d-learn wrote:
On Sun, 28 Sep 2014 04:24:19 +
Joel via Digitalmars-d-learn wrote:
struct Spot { bool dot; }
spots = new Spot[][](800,600);
btw, does anybody know why i can do `new ubyte[256];` but not
`new ubyte[256][256];`? hate that.
You can
On Sun, Sep 28, 2014 at 10:48:45AM +0300, ketmar via Digitalmars-d-learn wrote:
> On Sun, 28 Sep 2014 04:24:19 +
> Joel via Digitalmars-d-learn wrote:
>
> > struct Spot { bool dot; }
> > spots = new Spot[][](800,600);
> btw, does anybody know why i can do `new ubyte[256];` but not
> `new ubyt
On Sunday, 28 September 2014 at 04:24:25 UTC, Joel wrote:
I'm trying to make a multidimensional array. I feel I've tried
every thing. Is there a good guide explaining it?
struct Spot { bool dot; }
spots = new Spot[][](800,600);
assert(spots[800-1][600-1].dot, "Out of bounds");
You cou
On Sun, 28 Sep 2014 04:24:19 +
Joel via Digitalmars-d-learn wrote:
> struct Spot { bool dot; }
> spots = new Spot[][](800,600);
btw, does anybody know why i can do `new ubyte[256];` but not
`new ubyte[256][256];`? hate that.
signature.asc
Description: PGP signature
On Sunday, 28 September 2014 at 04:38:56 UTC, JKPdouble wrote:
On Sunday, 28 September 2014 at 04:24:25 UTC, Joel wrote:
I'm trying to make a multidimensional array. I feel I've tried
every thing. Is there a good guide explaining it?
struct Spot { bool dot; }
spots = new Spot[][](800,600);
On Sunday, 28 September 2014 at 04:24:25 UTC, Joel wrote:
I'm trying to make a multidimensional array. I feel I've tried
every thing. Is there a good guide explaining it?
struct Spot { bool dot; }
spots = new Spot[][](800,600);
assert(spots[800-1][600-1].dot, "Out of bounds");
dot is
On 11/14/2013 01:31 PM, seany wrote:
> I also note you have a book http://ddili.org/ders/d.en/index.html
> (too bad that there are chapters not translated, but thank you very
much)!
You are very welcome! Just three chapters left and I must add the UDA
chapter, which has been one of the most r
Oh, this is really nice, thank you very much
I also note you have a book http://ddili.org/ders/d.en/index.html
(too bad that there are chapters not translated, but thank you
very much)!
On Thursday, 14 November 2013 at 21:24:25 UTC, Ali Çehreli wrote:
On 11/14/2013 01:18 PM, seany wrote:
>
On 11/14/2013 01:18 PM, seany wrote:
> I See that in stack exchange, that it is possible to create
> multidimensional arrays like :
>
> [][] arrayname ;
That works because in C, C++, D, etc. a multi-dimensional array is
nothing but a single dimensional array where elements are arrays.
> I w
On 07/05/2013 09:00 PM, Oleksiy wrote:
> Look like there is a consequence - can't perform array-wise operations
> on multidimensional arrays?
I don't want to accept that conclusion because there is no such thing as
a multidimensional array in D. :) (To be fair, they don't exist in C and
C++.)
On Friday, 5 July 2013 at 01:31:00 UTC, Ali Çehreli wrote:
But this doesn't compile:
char[3][5] arr = [ '.', '.', '.' ];
Error: mismatched array lengths, 15 and 3
I see that as a bug but can't be sure.
I'd file a bug report, but since [x, y, z] is primarily a dynamic
array literal, I'd
However, that is a confusing syntax because the right-hand side
is not the same type as the elements, which is dchar[3].
Perhaps D supports it for C compatibility?
Yes, I noticed:
arr = '!';
Error: cannot implicitly convert expression ('!') of type char to
dchar[3u][]
Look like there is a c
Fixing it so that the sizes for static arrays were read
left-to-right would
definitely be a usability improvement, but even if we were to
decide that the
whole "read the type outward from the variable name" was
unimportant enough to
make the change desirable, it would silently break all kinds of
On Friday, 5 July 2013 at 01:53:22 UTC, Ali Çehreli wrote:
Now I have another array where the elements are of type int[3]:
int[3][2] arr = [ 10, 20, 30 ];
Error: mismatched array lengths, 6 and 3
Ali
Combined with the fact that *this* works:
int[3][2] arr = [ 10, 20, 30, 10, 20, 30 ];
On Thursday, 4 July 2013 at 23:02:10 UTC, Jonathan M Davis wrote:
On Friday, July 05, 2013 00:39:47 Oleksiy wrote:
Hi,
I'm new to the language and would appreciate if anybody could
clarify the following:
1. What is the rationale behind "prefix declaration" of an
array?
Using right-to-left or
On Friday, 5 July 2013 at 01:43:45 UTC, bearophile wrote:
There is a way to specify the type of a string, so this gives
errors:
void main() {
string s1 = "xx"d;
string s2 = "xx"w;
wstring s3 = "xx"d;
}
Bye,
bearophile
Also, don't forget the often forgotten explicit c suffix:
ds
Ali Çehreli:
int[3][2] arr = 10;
I would expect that to be an error because the element type is
not an int but int[3]. We know that an int[3] can be
initialized by 10 but a 10 should not be allowed to be used as
an int[3].
That was my point.
I see. That's another feature :-)
Bye,
be
On 07/04/2013 06:43 PM, bearophile wrote:
> Ali Çehreli:
>
>> However, that is a confusing syntax because the right-hand side is not
>> the same type as the elements, which is dchar[3]. Perhaps D supports
>> it for C compatibility?
>>
>> It doesn't match the following. Here, the right-hand side i
Ali Çehreli:
However, that is a confusing syntax because the right-hand side
is not the same type as the elements, which is dchar[3].
Perhaps D supports it for C compatibility?
It doesn't match the following. Here, the right-hand side is
the same as the element type:
int[2] arr2 = 42;
On 07/04/2013 03:39 PM, Oleksiy wrote:
> 1. What is the rationale behind "prefix declaration" of an array? Using
> right-to-left order to declare an array and left-to-right order to
> access elements seems confusing.
It seems to be confusing to people who are used to C and C++'s
inside-out defi
Oleksiy:
1. What is the rationale behind "prefix declaration" of an
array? Using right-to-left order to declare an array and
left-to-right order to access elements seems confusing.
I think the way Go language declares arrays and pointers is a bit
better. But for the rationale of this part of
On Friday, July 05, 2013 00:39:47 Oleksiy wrote:
> Hi,
>
> I'm new to the language and would appreciate if anybody could
> clarify the following:
>
> 1. What is the rationale behind "prefix declaration" of an array?
> Using right-to-left order to declare an array and left-to-right
> order to acce
28 matches
Mail list logo