Re: DMD JSON output

2017-02-25 Thread rikki cattermole via Digitalmars-d-learn
On 26/02/2017 4:01 PM, ANtlord wrote: Hello! I've encroutered intresting tool of DMD. It is dump of AST in JSON format (dmd -X main.d). But I it contains only declaration of methods, templates and structs. It doesn't contain statements like a variables or nested functions inside function's body.

DMD JSON output

2017-02-25 Thread ANtlord via Digitalmars-d-learn
Hello! I've encroutered intresting tool of DMD. It is dump of AST in JSON format (dmd -X main.d). But I it contains only declaration of methods, templates and structs. It doesn't contain statements like a variables or nested functions inside function's body. Is it possible to make dump with

Re: Recommend: IDE and GUI library

2017-02-25 Thread Moritz Maxeiner via Digitalmars-d-learn
On Saturday, 25 February 2017 at 21:26:32 UTC, XavierAP wrote: It's not GUI projects that I would plan to work on, just something easy with basic functionality that I can use for my own utilities or test clients for libraries. And if there's anything with any kind of designer support (in which

Re: trick to make throwing method @nogc

2017-02-25 Thread Profile Anaysis via Digitalmars-d-learn
On Saturday, 25 February 2017 at 19:59:29 UTC, ikod wrote: Hello, I have a method for range: struct Range { immutable(ubyte[]) _buffer; size_t _pos; @property void popFront() pure @safe { enforce(_pos < _buffer.length, "popFront from empty buffer");

Re: Recommend: IDE and GUI library

2017-02-25 Thread XavierAP via Digitalmars-d-learn
On Saturday, 25 February 2017 at 20:03:17 UTC, Jacob Carlborg wrote: There's no de factor library for creating GUIs in D. If you want a native look and feel, DWT is a good option. If you want the application to look the same on all platforms, there might be other better suited alternatives.

Re: trick to make throwing method @nogc

2017-02-25 Thread ikod via Digitalmars-d-learn
On Saturday, 25 February 2017 at 20:49:51 UTC, Adam D. Ruppe wrote: A wrapper that unifies these 4 steps like enforce is pretty easy to implement. yeah easy to use exception in @nogc as long as the catch knows to free it too. Alas, not my case. Exception can be catched not in my code.

Re: trick to make throwing method @nogc

2017-02-25 Thread Eugene Wissner via Digitalmars-d-learn
On Saturday, 25 February 2017 at 20:49:51 UTC, Adam D. Ruppe wrote: On Saturday, 25 February 2017 at 20:40:26 UTC, Eugene Wissner wrote: it builds and doesn't throw if I compile with: dmd -release though it causes a segfault, what is probably a dmd bug. No, that's by design. assert(0)

Re: trick to make throwing method @nogc

2017-02-25 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 25 February 2017 at 20:40:26 UTC, Eugene Wissner wrote: it builds and doesn't throw if I compile with: dmd -release though it causes a segfault, what is probably a dmd bug. No, that's by design. assert(0) compiles to a segfault instruction with -release. A wrapper that unifies

Re: trick to make throwing method @nogc

2017-02-25 Thread Eugene Wissner via Digitalmars-d-learn
On Saturday, 25 February 2017 at 20:02:56 UTC, ikod wrote: On Saturday, 25 February 2017 at 19:59:29 UTC, ikod wrote: Hello, I have a method for range: struct Range { immutable(ubyte[]) _buffer; size_t _pos; @property void popFront() pure @safe { enforce(_pos

Re: Recommend: IDE and GUI library

2017-02-25 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-02-24 23:44, XavierAP wrote: And second question, is DWT the de facto standard for creating GUIs? Or are there good competitors. There's no de factor library for creating GUIs in D. If you want a native look and feel, DWT is a good option. If you want the application to look the

Re: trick to make throwing method @nogc

2017-02-25 Thread ikod via Digitalmars-d-learn
On Saturday, 25 February 2017 at 19:59:29 UTC, ikod wrote: Hello, I have a method for range: struct Range { immutable(ubyte[]) _buffer; size_t _pos; @property void popFront() pure @safe { enforce(_pos < _buffer.length, "popFront from empty buffer");

Re: Serializer class

2017-02-25 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-02-24 19:10, houdoux09 wrote: The problem is that I can not retrieve the variables from the parent class. Cast the value to the type of the base class and run it through the same function. You can have a look at the Orange serialization library [1]. [1]

trick to make throwing method @nogc

2017-02-25 Thread ikod via Digitalmars-d-learn
Hello, I have a method for range: struct Range { immutable(ubyte[]) _buffer; size_t _pos; @property void popFront() pure @safe { enforce(_pos < _buffer.length, "popFront from empty buffer"); _pos++; } } I'd like to have @nogc here, but I can't

Re: Calling destroy on struct pointer

2017-02-25 Thread Moritz Maxeiner via Digitalmars-d-learn
On Saturday, 25 February 2017 at 15:13:27 UTC, Radu wrote: Here is sample on how destroy fails with a fwd decl error: struct A { B b; C c; } struct B { Wrap!A val; } struct C { Wrap!A val; } struct Wrap(T) { this(bool b) { t = cast(T*) malloc(T.sizeof);

Re: Calling destroy on struct pointer

2017-02-25 Thread Moritz Maxeiner via Digitalmars-d-learn
On Saturday, 25 February 2017 at 15:21:56 UTC, Radu wrote: The correct way of doing it using deref would to look like: struct A { int i; } auto a = cast (A*) malloc(A.sizeof); // Allocate emplace(a, 42); // Construct destroy(*a); // Destruct A

Re: Calling destroy on struct pointer

2017-02-25 Thread Radu via Digitalmars-d-learn
On Saturday, 25 February 2017 at 13:18:21 UTC, Moritz Maxeiner wrote: On Saturday, 25 February 2017 at 13:14:24 UTC, Moritz Maxeiner wrote: --- struct A {} auto a = cast (A*) malloc(A.sizeof); // Allocate emplace(a, 42); // Construct destroy(a);

Re: Calling destroy on struct pointer

2017-02-25 Thread Radu via Digitalmars-d-learn
On Saturday, 25 February 2017 at 13:14:24 UTC, Moritz Maxeiner wrote: On Saturday, 25 February 2017 at 10:44:07 UTC, Radu wrote: On Saturday, 25 February 2017 at 08:36:02 UTC, Ali Çehreli wrote: On 02/25/2017 12:17 AM, Radu wrote: > destroy(cc) -> does c = C.init > destroy(*cc); -> calls the

Re: [Beginner]Variable length arrays

2017-02-25 Thread helxi via Digitalmars-d-learn
On Saturday, 25 February 2017 at 14:34:31 UTC, rikki cattermole wrote: On 26/02/2017 3:31 AM, helxi wrote: I am trying to create an array which has a user defined size. However the following program is not compiling: import std.stdio; void main(){ write("Enter your array size: ");

Re: [Beginner]Variable length arrays

2017-02-25 Thread rikki cattermole via Digitalmars-d-learn
On 26/02/2017 3:31 AM, helxi wrote: I am trying to create an array which has a user defined size. However the following program is not compiling: import std.stdio; void main(){ write("Enter your array size: "); int n; readf(" %s", ); int[n] arr; //<-Error: variable input cannot

[Beginner]Variable length arrays

2017-02-25 Thread helxi via Digitalmars-d-learn
I am trying to create an array which has a user defined size. However the following program is not compiling: import std.stdio; void main(){ write("Enter your array size: "); int n; readf(" %s", ); int[n] arr; //<-Error: variable input cannot be read at compile time

Re: Pointers vs functional or array semantics

2017-02-25 Thread Ilya Yaroshenko via Digitalmars-d-learn
On Saturday, 25 February 2017 at 11:06:28 UTC, data pulverizer wrote: I have noticed that some numerical packages written in D use pointer semantics heavily (not referring to packages that link to C libraries). I am in the process of writing code for a numerical computing library and would

Re: Calling destroy on struct pointer

2017-02-25 Thread Moritz Maxeiner via Digitalmars-d-learn
On Saturday, 25 February 2017 at 13:14:24 UTC, Moritz Maxeiner wrote: --- struct A {} auto a = cast (A*) malloc(A.sizeof); // Allocate emplace(a, 42); // Construct destroy(a); // Destruct free(a); // Deallocate ---

Re: Calling destroy on struct pointer

2017-02-25 Thread Moritz Maxeiner via Digitalmars-d-learn
On Saturday, 25 February 2017 at 10:44:07 UTC, Radu wrote: On Saturday, 25 February 2017 at 08:36:02 UTC, Ali Çehreli wrote: On 02/25/2017 12:17 AM, Radu wrote: > destroy(cc) -> does c = C.init > destroy(*cc); -> calls the C dtor > > Is this by design? If so - how can I destroy and get the

Re: Pointers vs functional or array semantics

2017-02-25 Thread data pulverizer via Digitalmars-d-learn
On Saturday, 25 February 2017 at 11:15:53 UTC, ketmar wrote: data pulverizer wrote: I have noticed that some numerical packages written in D use pointer semantics heavily (not referring to packages that link to C libraries). I am in the process of writing code for a numerical computing

Re: Pointers vs functional or array semantics

2017-02-25 Thread ketmar via Digitalmars-d-learn
data pulverizer wrote: I have noticed that some numerical packages written in D use pointer semantics heavily (not referring to packages that link to C libraries). I am in the process of writing code for a numerical computing library and would like to know whether there times when addressing

Pointers vs functional or array semantics

2017-02-25 Thread data pulverizer via Digitalmars-d-learn
I have noticed that some numerical packages written in D use pointer semantics heavily (not referring to packages that link to C libraries). I am in the process of writing code for a numerical computing library and would like to know whether there times when addressing an array using pointers

Re: Calling destroy on struct pointer

2017-02-25 Thread Radu via Digitalmars-d-learn
On Saturday, 25 February 2017 at 08:36:02 UTC, Ali Çehreli wrote: On 02/25/2017 12:17 AM, Radu wrote: > destroy(cc) -> does c = C.init > destroy(*cc); -> calls the C dtor > > Is this by design? If so - how can I destroy and get the dtor called > without dereferencing the pointer? It's by

Re: Calling destroy on struct pointer

2017-02-25 Thread Ali Çehreli via Digitalmars-d-learn
On 02/25/2017 12:17 AM, Radu wrote: > destroy(cc) -> does c = C.init > destroy(*cc); -> calls the C dtor > > Is this by design? If so - how can I destroy and get the dtor called > without dereferencing the pointer? It's by design because setting a pointer to null can be considered as

Calling destroy on struct pointer

2017-02-25 Thread Radu via Digitalmars-d-learn
I'm puzzled by the way destroy works when passed a pointer to a struct, observe: --code.d-- int i; struct C { this(ref int i) { ++i; ii = } ~this() {