On Thursday, 17 April 2014 at 00:55:19 UTC, Dicebot wrote:
Just in case, the key line to pay attention to in that example
is this one:
CellIndex[0] c_;
It is a commonly used C idiom for dynamically sized structures
that D also supports.
Absolutely. However, from a technical point of view, i
On Wednesday, 16 April 2014 at 23:36:05 UTC, bearophile wrote:
Jeroen Bollen:
Is it possible to have a structure with a dynamic size?
See an usage example I have written here:
http://rosettacode.org/wiki/Sokoban#Faster_Version
But that code requires a very updated compiler. Otherwise you
wi
On Wednesday, 16 April 2014 at 23:15:43 UTC, Jeroen Bollen wrote:
Is it possible to have a structure with a dynamic size? The
structure would contain an array.
I know I can use templates, but the size won't be known at
compile time. I also know I could just put a dynamic array into
it, but th
Jeroen Bollen:
Is it possible to have a structure with a dynamic size?
See an usage example I have written here:
http://rosettacode.org/wiki/Sokoban#Faster_Version
But that code requires a very updated compiler. Otherwise you
will need a little different code.
Bye,
bearophile
On Wed, 16 Apr 2014 23:15:40 +, Jeroen Bollen wrote:
> Is it possible to have a structure with a dynamic size? The structure
> would contain an array.
>
> I know I can use templates, but the size won't be known at compile time.
> I also know I could just put a dynamic array into it, but that
Well, I'm still confused by this. I also noticed that the compiler
doesn't complain if I omit the break statements in the generated
switch, but complains normally if I write it out like so:
```
switch (key)
{
case 1: "Found 1!".writefln();
break;
case 2: "Fo
Is it possible to have a structure with a dynamic size? The
structure would contain an array.
I know I can use templates, but the size won't be known at
compile time. I also know I could just put a dynamic array into
it, but that way it would just be a pointer.
I know there would be major is
On Wednesday, 16 April 2014 at 21:05:30 UTC, Hannes Steffenhagen
wrote:
I've looked at std.stream, but it says in big red scary letters
that I probably shouldn't be using it. Is there a suitable
replacement? If not, I'd just roll my own and provide a couple
of templates to automatically generat
I've looked at std.stream, but it says in big red scary letters
that I probably shouldn't be using it. Is there a suitable
replacement? If not, I'd just roll my own and provide a couple of
templates to automatically generate wrappers for them.
Thanks everyone for figuring everything out!
It also throws if you input initial or trailing spaces and there
are no spaces at the start or end of format string (scanf skips
these spaces)
On Wednesday, 16 April 2014 at 18:46:18 UTC, Ali Çehreli wrote:
On 04/16/2014 11:36 AM, FreeSlave wrote:
Note that readf is not equivalent to scanf since readf does
not skip
spaces and newline character. Input must completely match
format.
Just like in scanf, a single space character is suffi
On 04/16/2014 11:36 AM, FreeSlave wrote:
Note that readf is not equivalent to scanf since readf does not skip
spaces and newline character. Input must completely match format.
Just like in scanf, a single space character is sufficient to consume
zero or more whitespace characters.
Ali
Note that readf is not equivalent to scanf since readf does not
skip spaces and newline character. Input must completely match
format.
On Wednesday, 16 April 2014 at 17:20:52 UTC, Adam D. Ruppe wrote:
OK, you could also store a pointer to the InputRange as your
member.
With structs, assignment is making a private copy, so if you
want to update the original in a stored thing you'll need the
pointer. ref doesn't work with anyt
On Wed, 16 Apr 2014 18:17:37 +, Capture_A_Lag wrote:
> Thank you everybody!!!
> I thought %d is ok for all integral types.
This is true when using the D format functions (e.g. readf) which are
able to inspect the types of the variables being assigned, but scanf is a
C function and not types
Thank you everybody!!!
I thought %d is ok for all integral types.
On Wednesday, 16 April 2014 at 17:47:05 UTC, Capture_A_Lag wrote:
Hi all!
I have this code:
--
ubyte N, M, K;
ubyte[][max][max] Matrix;
scanf("%d %d %d", &N, &M, &K);
ubyte tmp;
for(ubyte n = 1; n <= N; n++)
f
On Wednesday, 16 April 2014 at 17:47:05 UTC, Capture_A_Lag wrote:
Hi all!
I have this code:
--
ubyte N, M, K;
ubyte[][max][max] Matrix;
scanf("%d %d %d", &N, &M, &K);
ubyte tmp;
for(ubyte n = 1; n <= N; n++)
f
On 04/16/2014 10:47 AM, Capture_A_Lag wrote:
> ubyte tmp;
> scanf("%d", &tmp);
> // After this scanf n becomes 0 for no reason
%d is for int.
Ali
P.S. A friendly request: It makes it much easier for the rest of the
group if posts contained compilable, minimal but co
On Wed, 16 Apr 2014 17:47:03 +, Capture_A_Lag wrote:
> Hi all!
> I have this code:
>
>
--
> ubyte N, M, K;
> ubyte[][max][max] Matrix;
>
> scanf("%d %d %d", &N, &M, &K);
>
> ubyte tmp;
>
> for(ubyte n = 1; n <= N;
Capture_A_Lag:
After scanf in loop variable n becomes 0. Is this a bug? Please
help me!
Have you tried to use a tmp of type int to avoid stomping?
Bye,
bearophile
Hi all!
I have this code:
--
ubyte N, M, K;
ubyte[][max][max] Matrix;
scanf("%d %d %d", &N, &M, &K);
ubyte tmp;
for(ubyte n = 1; n <= N; n++)
for(ubyte m = 1; m <= M; m++)
{
scanf("%d",
OK, you could also store a pointer to the InputRange as your
member.
With structs, assignment is making a private copy, so if you want
to update the original in a stored thing you'll need the pointer.
ref doesn't work with anything other than function arguments in D.
On Wednesday, 16 April 2014 at 16:21:42 UTC, Adam D. Ruppe wrote:
What's the definition of InputRange? Is it the interface from
std.range?
If so, don't pass it as ref. interfaces are references to the
object by default.
In general, you only need ref when you want to assign a new
object to t
What's the definition of InputRange? Is it the interface from
std.range?
If so, don't pass it as ref. interfaces are references to the
object by default.
In general, you only need ref when you want to assign a new
object to the variable and want that change to be seen outside
the function t
The following:
this(ref InputRange r) {
writeln(&r);
this.r = r;
writeln(&this.r);
}
7FFF2BD74D50 // r
7FFF2BD745F0 // this.r
Why? And how can I change this?
Why does the read function return void[] and not byte[]
void[] read(in char[] name, size_t upTo = size_t.max);
On Tuesday, April 15, 2014 18:01:59 bearophile wrote:
> Steve Teale:
> > Since this is D-Learn, I can be indignant, and say that D needs
> > to get its act together, and have a clean definition of 'pure'.
> > What you describe is not only undocumented, but also far too
> > complicated - pure weak n
29 matches
Mail list logo