multi-dimensional dynamic arrays

2016-02-18 Thread Jay Norwood via Digitalmars-d-learn
Strange to me that this compiles, since I would expect there to be some C-like limitation on the position of the unspecified dimension. Is allowing this somehow useful? int[1][][1] ub; writeln("ub",ub);

Modify Function Pointer to Take Additional Parameters

2016-02-18 Thread jmh530 via Digitalmars-d-learn
I'm trying to write a function that will adjust the parameters of a function pointer. In the code below, my goal is to call the function qux with a variety of different function pointers (in the actual application, I don't have the ability to modify qux). I created a function foo that I thoug

Re: Duration at runtime

2016-02-18 Thread Zekereth via Digitalmars-d-learn
On Friday, 19 February 2016 at 04:21:43 UTC, Zekereth wrote: On Friday, 19 February 2016 at 04:16:23 UTC, Adam D. Ruppe wrote: On Friday, 19 February 2016 at 04:08:02 UTC, Zekereth wrote: How is seconds able to be read at compile time but unitType cannot? "seconds" is a literal value that the

Re: Duration at runtime

2016-02-18 Thread Zekereth via Digitalmars-d-learn
On Friday, 19 February 2016 at 04:16:23 UTC, Adam D. Ruppe wrote: On Friday, 19 February 2016 at 04:08:02 UTC, Zekereth wrote: How is seconds able to be read at compile time but unitType cannot? "seconds" is a literal value that the compiler knows about. unitType is a variable that might chan

Re: Duration at runtime

2016-02-18 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 19 February 2016 at 04:08:02 UTC, Zekereth wrote: How is seconds able to be read at compile time but unitType cannot? "seconds" is a literal value that the compiler knows about. unitType is a variable that might change between its declaration and use (it doesn't here, but the compi

Duration at runtime

2016-02-18 Thread Zekereth via Digitalmars-d-learn
I'm confused by the following: import std.stdio; import std.datetime; void main() { string unitType = "seconds"; auto seconds = 1; // auto myDur = dur!(unitType)(seconds); // Error unitType can't be read at compile time. auto myDur = dur!("seconds")(seconds); // Compile

Re: Arrays of noncopyables/Invalid memory operation

2016-02-18 Thread H. S. Teoh via Digitalmars-d-learn
On Thu, Feb 18, 2016 at 05:18:33PM -0800, Ali Çehreli via Digitalmars-d-learn wrote: > On 02/18/2016 12:12 PM, Ali Çehreli wrote: > > > > Hmm, why does the destructor of object 60 run in the middle of > > > nowhere? > > > > It so happens that the GC decides to collect when moving the array > >

Re: Arrays of noncopyables/Invalid memory operation

2016-02-18 Thread Ali Çehreli via Digitalmars-d-learn
On 02/18/2016 12:12 PM, Ali Çehreli wrote: > > Hmm, why does the destructor of object 60 run in the middle of nowhere? > > It so happens that the GC decides to collect when moving the array to a > new location at that point. If you add the following to the beginning of > main, you will see tha

Re: Installing DUB on OSX

2016-02-18 Thread Joel via Digitalmars-d-learn
On Thursday, 18 February 2016 at 16:33:51 UTC, John Colvin wrote: On Thursday, 18 February 2016 at 07:52:11 UTC, Joel wrote: On Thursday, 18 February 2016 at 07:11:23 UTC, Joel wrote: I had dub installed in a folder that meant I had to put 'sudo dub' to run it. I've tried to fix the problem, bu

Re: Why is there no combination of popFront and front to pop? (aka Python `next`)

2016-02-18 Thread Ali Çehreli via Digitalmars-d-learn
On 02/18/2016 05:04 AM, Seb wrote: > However on the other side we learn the stack syntax with return at > university You must have seen it in the context of reference types, no? There is no problem in languages that don't have value types. The problem is with the final copying of the value to

Re: Arrays of noncopyables/Invalid memory operation

2016-02-18 Thread Ali Çehreli via Digitalmars-d-learn
On 02/17/2016 07:00 PM, ZombineDev wrote: > On Thursday, 18 February 2016 at 01:19:16 UTC, Ali Çehreli wrote: >> On 02/17/2016 05:14 PM, ZombineDev wrote: >> >> > The "Invalid memory operation" error is thrown only by the GC >> (AFAIK) >> > when the user tries something unsupported like allocating

Re: Installing DUB on OSX

2016-02-18 Thread Jacob Carlborg via Digitalmars-d-learn
On 2016-02-18 10:55, Edwin van Leeuwen wrote: sudo cp dub /usr/bin/ It should say in /usr/local/bin. Because users don't have write access to /usr/bin on OS X 10.11, even with sudo. -- /Jacob Carlborg

Re: ndslice help

2016-02-18 Thread Zz via Digitalmars-d-learn
On Thursday, 18 February 2016 at 02:24:20 UTC, ZombineDev wrote: On Thursday, 18 February 2016 at 00:25:09 UTC, Zz wrote: Hi, I'm trying to generate the following sequences with ndslice. 0 0 0 1 1 1 1 1 1 0 0 0 0 1 2 0 1 2 2 1 0 2 1 0 It's okay with loops but was checking to see if it's po

Re: Installing DUB on OSX

2016-02-18 Thread John Colvin via Digitalmars-d-learn
On Thursday, 18 February 2016 at 07:52:11 UTC, Joel wrote: On Thursday, 18 February 2016 at 07:11:23 UTC, Joel wrote: I had dub installed in a folder that meant I had to put 'sudo dub' to run it. I've tried to fix the problem, but where do you put it (also I tried one place, but couldn't put it

Re: Why is there no combination of popFront and front to pop? (aka Python `next`)

2016-02-18 Thread Seb via Digitalmars-d-learn
On Thursday, 18 February 2016 at 13:04:09 UTC, Seb wrote: Anyways I will try my best to submit a PR and we can continue to discuss pros/cons there - imho it's an excellent learning task :) Update: Yeah I submitted my first PR to phobos: https://github.com/D-Programming-Language/phobos/pull/40

Re: Why is there no combination of popFront and front to pop? (aka Python `next`)

2016-02-18 Thread Seb via Digitalmars-d-learn
On Wednesday, 17 February 2016 at 11:30:40 UTC, Jonathan M Davis wrote: Feel free to create a pull request to add next. I don't know if it would be accepted or not. I suspect that it mainly comes down to whether such a simple function would be deemed worth adding. On some level, it is a usabili

Re: Enforcing checks for return code

2016-02-18 Thread Marc Schütz via Digitalmars-d-learn
On Thursday, 18 February 2016 at 07:21:05 UTC, Chris Katko wrote: Hello. I'm almost brand-new to the D language and still absorbing things. I'm wondering if it's possible to fire off a compile-time (or worst case, a run-time) warning or error if a function is called, but the return value is n

Re: Enforcing checks for return code

2016-02-18 Thread tsbockman via Digitalmars-d-learn
On Thursday, 18 February 2016 at 07:21:05 UTC, Chris Katko wrote: Hello. I'm almost brand-new to the D language and still absorbing things. I'm wondering if it's possible to fire off a compile-time (or worst case, a run-time) warning or error if a function is called, but the return value is n

Re: Enforcing checks for return code

2016-02-18 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, February 18, 2016 07:21:05 Chris Katko via Digitalmars-d-learn wrote: > Hello. I'm almost brand-new to the D language and still absorbing > things. > > I'm wondering if it's possible to fire off a compile-time (or > worst case, a run-time) warning or error if a function is called, > b

Re: Installing DUB on OSX

2016-02-18 Thread Edwin van Leeuwen via Digitalmars-d-learn
On Thursday, 18 February 2016 at 09:25:00 UTC, Joel wrote: On Thursday, 18 February 2016 at 08:24:34 UTC, Jacob Carlborg wrote: On 2016-02-18 08:11, Joel wrote: I had dub installed in a folder that meant I had to put 'sudo dub' to run it. I've tried to fix the problem, but where do you put it

Re: Installing DUB on OSX

2016-02-18 Thread Joel via Digitalmars-d-learn
On Thursday, 18 February 2016 at 08:24:34 UTC, Jacob Carlborg wrote: On 2016-02-18 08:11, Joel wrote: I had dub installed in a folder that meant I had to put 'sudo dub' to run it. I've tried to fix the problem, but where do you put it (also I tried one place, but couldn't put it in that folder

Re: Installing DUB on OSX

2016-02-18 Thread Jacob Carlborg via Digitalmars-d-learn
On 2016-02-18 08:11, Joel wrote: I had dub installed in a folder that meant I had to put 'sudo dub' to run it. I've tried to fix the problem, but where do you put it (also I tried one place, but couldn't put it in that folder)? You usually have read access to most paths. That means you should b

Re: Installing DUB on OSX

2016-02-18 Thread Guillaume Piolat via Digitalmars-d-learn
On Thursday, 18 February 2016 at 07:52:11 UTC, Joel wrote: On Thursday, 18 February 2016 at 07:11:23 UTC, Joel wrote: I had dub installed in a folder that meant I had to put 'sudo dub' to run it. I've tried to fix the problem, but where do you put it (also I tried one place, but couldn't put it