Re: cannot access frame of function

2018-03-22 Thread Jordan Wilson via Digitalmars-d-learn
On Monday, 18 September 2017 at 21:58:39 UTC, Alex wrote: On Monday, 18 September 2017 at 18:49:54 UTC, ag0aep6g wrote: Doesn't work for me. This still fails compilation with the same error: import std.algorithm.iteration : sum, cumulativeFold; void main() { double[5] a; auto as

remote execute program

2018-03-22 Thread Cecil Ward via Digitalmars-d-learn
I am wanting to write a short program (on a ‘server’ you could say) that takes a command, runs it (as on the command line, so an executable with arguments or a shell command) and returns a 3-tuple with an int for the return code, plus the textual outputs that it generates to stdout and stderr.

Re: Building Derelict based application under windows

2018-03-22 Thread Mike Parker via Digitalmars-d-learn
On Thursday, 22 March 2018 at 20:51:36 UTC, ANtlord wrote: Thanks in advance. Please feel free to ask any question Your errors with the derelict libs are linker errors, with the early ones being this one: "warning LNK4003: invalid library format; library ignored" At the top of the output,

Re: #import mapi.h

2018-03-22 Thread Mike Parker via Digitalmars-d-learn
On Thursday, 22 March 2018 at 21:45:40 UTC, Martin Tschierschke wrote: On Thursday, 22 March 2018 at 17:42:46 UTC, Paul Backus wrote: On Wednesday, 21 March 2018 at 16:22:45 UTC, Martin Tschierschke wrote: Is there an step by step introduction how to convert a C header of an external lib into t

Re: #import mapi.h

2018-03-22 Thread Martin Tschierschke via Digitalmars-d-learn
On Thursday, 22 March 2018 at 17:42:46 UTC, Paul Backus wrote: On Wednesday, 21 March 2018 at 16:22:45 UTC, Martin Tschierschke wrote: Is there an step by step introduction how to convert a C header of an external lib into the right extern(C){} block? In addition to what others have said, I fo

Building Derelict based application under windows

2018-03-22 Thread ANtlord via Digitalmars-d-learn
Hello! First of all I don't know what my problem is but please don't close the thread and give me a chance. I have been working on DMD under Linux since I met D. Short time ago I got a reason to make an application for Windows. I took DerelictAL[1], DerelictOgg[2] and DerelictVorbis[3] impleme

Re: Help debugging an core.exception.OutOfMemoryError

2018-03-22 Thread Ali Çehreli via Digitalmars-d-learn
On 03/22/2018 02:45 AM, Danny Arends wrote: Hey all, When running a D program that i wrote (32bit mode, windows10), an OutOfMemory exception being thrown when executing the program: core.exception.OutOfMemoryError@src\core\exception.d(702): Memory allocation failed However there is no stac

Re: Checking if a flag was passed to the compiler

2018-03-22 Thread Nordlöw via Digitalmars-d-learn
On Thursday, 22 March 2018 at 14:58:56 UTC, Seb wrote: For reference and completeness, a simple example: ```d void main() { enum isDIP1000 = __traits(compiles, () @safe { int x; int* p; p = &x; }); pragma(msg, isDIP1000); } ``` normal: https://run.dlang.io

Re: Is it possible to exit a contract?

2018-03-22 Thread berni via Digitalmars-d-learn
On Thursday, 22 March 2018 at 16:22:04 UTC, Ali Çehreli wrote: Never thought of it before. :) I would put all that code into a function and call from the out block. I rejected this, because I've got an unease feeling using extra functions in contract programming. Can't tell, where this feeling

Re: #import mapi.h

2018-03-22 Thread Paul Backus via Digitalmars-d-learn
On Wednesday, 21 March 2018 at 16:22:45 UTC, Martin Tschierschke wrote: Is there an step by step introduction how to convert a C header of an external lib into the right extern(C){} block? In addition to what others have said, I found the following article on the D Wiki useful: https://wiki.

Re: Is it possible to exit a contract?

2018-03-22 Thread Simen Kjærås via Digitalmars-d-learn
On Thursday, 22 March 2018 at 13:16:00 UTC, berni wrote: Part of my code looks like this: out (result) { if (result==true) { lots of assertions... } } I would prefer an early exit like: out (result) { if (result==false) return; lots of assertions... } Is this possible someh

Re: Is it possible to exit a contract?

2018-03-22 Thread Ali Çehreli via Digitalmars-d-learn
On 03/22/2018 06:16 AM, berni wrote: Part of my code looks like this: out (result) {   if (result==true)   {     lots of assertions...   } } I would prefer an early exit like: out (result) {   if (result==false) return;   lots of assertions... } Is this possible somehow (return and break

Re: OK, I'm stumped on this one: dstep, struct, mixin, bitfields

2018-03-22 Thread Jacob Carlborg via Digitalmars-d-learn
On Thursday, 22 March 2018 at 09:55:44 UTC, Russel Winder wrote: I am guessing you mean against DStep rather than D :-) Yes :) Though clearly T and I would prefer version not to be a D keyword. I suspect I have seen one place where DStep has turned version into version_ where version was

Re: why does this compile fine, but dies when you run it.

2018-03-22 Thread Nicholas Wilson via Digitalmars-d-learn
On Thursday, 22 March 2018 at 14:05:02 UTC, steven kladitis wrote: -- what is the difference between int[] x; and int[int] x; int[] x; is like struct _Int_Array { size_t len; int* ptr; } _Int_Array y; int i = 5; x[i] = i; // this and the line below crash or assert, due to a null p

Re: Checking if a flag was passed to the compiler

2018-03-22 Thread Seb via Digitalmars-d-learn
On Thursday, 22 March 2018 at 12:02:40 UTC, Nicholas Wilson wrote: On Thursday, 22 March 2018 at 10:08:31 UTC, Nordlöw wrote: Is there a way to check in code whether a specific flag, -dip1000 in my case, was passed to the compiler? Most command line arguments that are detectable set a version,

Re: #import mapi.h

2018-03-22 Thread Kagamin via Digitalmars-d-learn
On Wednesday, 21 March 2018 at 16:22:45 UTC, Martin Tschierschke wrote: Is there an step by step introduction how to convert a C header of an external lib into the right extern(C){} block? In short, they should be binary compatible: where is a pointer on C side, should be a pointer on D side,

Re: #import mapi.h

2018-03-22 Thread Martin Tschierschke via Digitalmars-d-learn
On Thursday, 22 March 2018 at 12:53:23 UTC, Martin Tschierschke wrote: On Wednesday, 21 March 2018 at 17:12:07 UTC, Timoses wrote: [...] I got it, my first mini test with C bindings! Important missing at first: (stderr) import core.stdc.stdio : stderr, FILE; and use of toStringz inside: mapi_

Re: why does this compile fine, but dies when you run it.

2018-03-22 Thread steven kladitis via Digitalmars-d-learn
On Wednesday, 21 March 2018 at 18:55:34 UTC, Adam D. Ruppe wrote: On Wednesday, 21 March 2018 at 18:53:39 UTC, steven kladitis wrote: int[] array3; array3[0]=4; array3 is empty. You are trying to set a value that doesn't exist.. import std.stdio; void main(){ int[3] array1 = [ 10, 20, 30 ]

Re: Static Arrays: Behaviour of Passing & Returning

2018-03-22 Thread Quantum Nerd via Digitalmars-d-learn
On Wednesday, 21 March 2018 at 12:15:13 UTC, Simen Kjærås wrote: I'm pretty sure you're seeing NRVO - Named Return Value Optimization. Also called copy elision: https://en.wikipedia.org/wiki/Copy_elision The compiler sees that when you return r, it's immediately assigned to b. Since it's a

Is it possible to exit a contract?

2018-03-22 Thread berni via Digitalmars-d-learn
Part of my code looks like this: out (result) { if (result==true) { lots of assertions... } } I would prefer an early exit like: out (result) { if (result==false) return; lots of assertions... } Is this possible somehow (return and break don't do the job...). The only thing

Re: #import mapi.h

2018-03-22 Thread Martin Tschierschke via Digitalmars-d-learn
On Wednesday, 21 March 2018 at 17:12:07 UTC, Timoses wrote: On Wednesday, 21 March 2018 at 16:22:45 UTC, Martin Tschierschke wrote: Is there an step by step introduction how to convert a C header of an external lib into the right extern(C){} block? A blog post or tutorial, or chapter in a D bo

Re: #import mapi.h

2018-03-22 Thread Martin Tschierschke via Digitalmars-d-learn
On Wednesday, 21 March 2018 at 18:42:43 UTC, nkm1 wrote: On Wednesday, 21 March 2018 at 16:22:45 UTC, Martin Tschierschke wrote: [...] The easiest thing to do is to write a wrapper in C. The wrapper will include all necessary headers and provide some easy to use functions that you can call f

Re: Checking if a flag was passed to the compiler

2018-03-22 Thread Nicholas Wilson via Digitalmars-d-learn
On Thursday, 22 March 2018 at 10:08:31 UTC, Nordlöw wrote: Is there a way to check in code whether a specific flag, -dip1000 in my case, was passed to the compiler? Most command line arguments that are detectable set a version, e.g. D_Coverage, unittest, assert,D_BetterC. I don't see dip1000

Re: Is there a way to pipeline program with random-access ranges in C#?

2018-03-22 Thread Dukc via Digitalmars-d-learn
On Thursday, 22 March 2018 at 09:59:28 UTC, Kagamin wrote: On Thursday, 22 March 2018 at 09:04:12 UTC, Dukc wrote: So the real difference is that random-accesss ranges are not input-ranges in C# (or Rust, judging by a quick look I recently took) but can be used to fetch one. A bit cumbersome p

Re: Issue with traits usability

2018-03-22 Thread Simen Kjærås via Digitalmars-d-learn
On Wednesday, 21 March 2018 at 15:36:01 UTC, Márcio Martins wrote: Hi! How do I get past this? static struct X { int x; private enum T = 1; private alias M = string; } foreach (Member; __traits(allMembers, X)) { pragma(msg, __traits(getProtection, __traits(getMember,

Re: OK, I'm stumped on this one: dstep, struct, mixin, bitfields

2018-03-22 Thread Kagamin via Digitalmars-d-learn
On Wednesday, 21 March 2018 at 19:41:39 UTC, H. S. Teoh wrote: version(all) { ... } version(none) { ... } version(Posix) { ... } version(Windows) { ... } But yeah, using "version" for this purpose makes the very common identifier "version" unavailable for use. I

Checking if a flag was passed to the compiler

2018-03-22 Thread Nordlöw via Digitalmars-d-learn
Is there a way to check in code whether a specific flag, -dip1000 in my case, was passed to the compiler?

Re: Is there a way to pipeline program with random-access ranges in C#?

2018-03-22 Thread Kagamin via Digitalmars-d-learn
On Thursday, 22 March 2018 at 09:04:12 UTC, Dukc wrote: So the real difference is that random-accesss ranges are not input-ranges in C# (or Rust, judging by a quick look I recently took) but can be used to fetch one. A bit cumbersome perhaps, but logical. I think I understand it now. Thank you.

Re: OK, I'm stumped on this one: dstep, struct, mixin, bitfields

2018-03-22 Thread Russel Winder via Digitalmars-d-learn
On Wed, 2018-03-21 at 22:18 +0100, Jacob Carlborg via Digitalmars-d-learn wrote: > On 2018-03-21 20:30, Russel Winder wrote: > > > Thanks to Adam and Ali, it was clear and obvious. > > Please report and issue so it's not forgotten. I am guessing you mean against DStep rather than D :-) Though c

Help debugging an core.exception.OutOfMemoryError

2018-03-22 Thread Danny Arends via Digitalmars-d-learn
Hey all, When running a D program that i wrote (32bit mode, windows10), an OutOfMemory exception being thrown when executing the program: core.exception.OutOfMemoryError@src\core\exception.d(702): Memory allocation failed However there is no stack trace being generated (due to the program

Re: Is there a way to pipeline program with random-access ranges in C#?

2018-03-22 Thread Dukc via Digitalmars-d-learn
On Wednesday, 21 March 2018 at 08:40:25 UTC, Kagamin wrote: On Wednesday, 21 March 2018 at 07:40:01 UTC, Dukc wrote: ...except that IEnumerables cannot popBack(), so can only do that by doing an additional copy and reversing that. But I quess there's no better alternative, short of doing it C-

Re: Understanding slide

2018-03-22 Thread Jordan Wilson via Digitalmars-d-learn
On Thursday, 22 March 2018 at 03:58:35 UTC, Seb wrote: On Thursday, 22 March 2018 at 03:39:38 UTC, Jordan Wilson wrote: auto a = iota(5).slide!(Yes.withPartial)(3); auto b = iota(5).slide!(No.withPartial)(3); assert (a.equal(b)); The assert passes, but I would expect it to fail? They both are:

Re: Manipulate slice or specific element of range and return range

2018-03-22 Thread David Bennett via Digitalmars-d-learn
On Thursday, 22 March 2018 at 04:49:39 UTC, Seb wrote: No need for regular expressions. D is powerful enough without them: ``` alias lowercased = (m, n) => m.take(n).asLowerCase.chain(m.drop(n)); ``` https://run.dlang.io/is/cSL0si And with the filter, so it passes the assert: ``` string

Re: recursive template expansion: Why does this not compile?

2018-03-22 Thread Ontonator via Digitalmars-d-learn
On Wednesday, 21 March 2018 at 23:05:22 UTC, Jonathan M Davis wrote: On Wednesday, March 21, 2018 22:50:32 Ontonator via Digitalmars-d-learn wrote: On Wednesday, 21 March 2018 at 06:39:22 UTC, ag0aep6g wrote: > On 03/21/2018 01:47 AM, Ontonator wrote: >> The following code does not compile: >>>