static array of pointers to dynamic arrays of ints problem...

2018-04-22 Thread WhatMeForget via Digitalmars-d-learn
Surely a stupid mistake on my part, but why is the first array repeated? import std.stdio; void main() { int[]*[2] a; // a static arrray holding pointers to dynamic arrays static int unique = 0; foreach(i, elem; a) { int[] temp = new int[](5); foreach(ref

why use string for this example of appender?

2018-04-16 Thread WhatMeForget via Digitalmars-d-learn
I think I got a handle on D's static and dynamic arrays, till I come to std.array and see all the shiny new tools. I can understand all the replace.. functions, but the appender function gave me pause. The documentation says appender "Returns a new Appender or RefAppender initialized with a

Re: Infuriating DUB/DMD build bug.

2017-10-07 Thread WhatMeForget via Digitalmars-d-learn
On Friday, 6 October 2017 at 23:02:56 UTC, Laeeth Isharc wrote: On Thursday, 5 October 2017 at 21:48:20 UTC, WhatMeWorry wrote: I've got a github project and using DUB with DMD and I keep running into this problem. I've tried deleting the entire ...\AppData\Roaming\dub\packages folder, but

Real beginner traits question

2017-09-24 Thread WhatMeForget via Digitalmars-d-learn
This is taken exactly from the traits documentation. 25 Traits 25.21 identifier Takes one argument, a symbol. Returns the identifier for that symbol as a string literal. There are no

Re: Mixed up over mixins.

2017-08-21 Thread WhatMeForget via Digitalmars-d-learn
On Sunday, 20 August 2017 at 22:50:40 UTC, Johnson Jones wrote: On Sunday, 20 August 2017 at 19:27:43 UTC, WhatMeWorry wrote: [...] It's not difficult, it's just new. It's not that you are a poor programmer, but you simply have not learned how to think about mixins correctly. Stop whining

Re: Mixed up over mixins.

2017-08-21 Thread WhatMeForget via Digitalmars-d-learn
On Sunday, 20 August 2017 at 19:41:14 UTC, Ali Çehreli wrote: On 08/20/2017 12:27 PM, WhatMeWorry wrote: > // Mixins are for mixing in generated code into the source code. > // The mixed in code may be generated as a template instance > // or a string. Yes, it means that the string

real simple delegate question.

2017-08-17 Thread WhatMeForget via Digitalmars-d-learn
Can someone explain what is the difference between the two? Thanks. module gates; import std.stdio; import std.random; alias Calculator = int delegate(int); Calculator makeCalculator() { static int context = 0; int randy = uniform(1, 7); context++; writeln("context = ",

Real naive template question

2017-08-13 Thread WhatMeForget via Digitalmars-d-learn
module block_template; void main() { template BluePrint(T, U) { T integer; U floatingPoint; } BluePrint!(int, float); } // DMD returns // template.d(13): Error: BluePrint!(int, float) has no effect // I was expecting something like the following to be created

I feel the dynamic array .sizeof property is kind of a bait and switch

2017-07-25 Thread WhatMeForget via Digitalmars-d-learn
Static Arrays have property .sizeof which returns the array length multiplied by the number of bytes per array element. Dynamic Arrays have property .sizeof which returns the size of the dynamic array reference, which is 8 in 32-bit builds and 16 on 64-bit builds. Why not have dynamic

Re: Is it possible to generate a pool of random D or D inline assembler programs, run them safely?

2017-07-19 Thread WhatMeForget via Digitalmars-d-learn
On Tuesday, 18 July 2017 at 17:35:17 UTC, Enjoys Math wrote: The purpose of it is to make a real-time, short-lived function predictor. I'm genuinely curious. What is a function predictor used for?

Why doesn't this work...Struct std.regex.Captures

2017-07-09 Thread WhatMeForget via Digitalmars-d-learn
I was playing around with regex import std.regex; import std.stdio; void main() { string[] fileNames = [ "011_bad.txt", "01_01_pass", "90_pass", "_bad" ]; auto reg = regex(r"^\d{2}_"); foreach (name; fileNames) { auto c = matchFirst(name, reg);

First time user of LDC and getting newbie problems.

2017-06-11 Thread WhatMeForget via Digitalmars-d-learn
Just trying to compile a "Hello World" using dub and ldc2. The 32 bit works fine: generic@generic-ThinkPad-T61:~/Desktop/test$ dub run --compiler=ldc2 --arch=x86 Performing "debug" build using ldc2 for x86. test ~master: target for configuration "application" is up to date. To force a

real simple manifest constant question probably regret asking...

2017-03-15 Thread WhatMeForget via Digitalmars-d-learn
One of my D books says: "an enum declared without any braces is called a manifest constant." The example shows, enum string author = "Mike Parker"; Is this equivalent to const string author = "Mike Parker"; or immutable string author = "Mike Parker"; I guess what I'm asking is does enum

Re: simple static if / traits question...

2017-02-22 Thread WhatMeForget via Digitalmars-d-learn
On Wednesday, 22 February 2017 at 22:37:25 UTC, Profile Anaysis wrote: On Wednesday, 22 February 2017 at 21:27:47 UTC, WhatMeWorry wrote: I'm doing conditional compilation using static ifs like so: enum bool audio = true; // if audio flag is present and set to true, add to code

Re: Array start index

2017-02-06 Thread WhatMeForget via Digitalmars-d-learn
On Saturday, 1 August 2015 at 09:35:53 UTC, DLearner wrote: Does the D language set in stone that the first element of an array _has_ to be index zero? Wouldn't starting array elements at one avoid the common 'off-by-one' logic error, it does seem more natural to begin a count at 1. Actually,

Re: Should I brush up on my C before plunging fully into D?

2016-10-15 Thread WhatMeForget via Digitalmars-d-learn
On Saturday, 15 October 2016 at 01:46:52 UTC, Chris Nelson wrote: I'm mainly a scripting language, .NET, and SQL programmer. I've been looking for a good programming language for Linux/BSD other than Python. I've surveyed the options and D appears to be a sane modern choice for me. (Thanks Ali