Re: mir.ndslice : multi dimensional associative array - Example/Docs

2020-10-26 Thread 9il via Digitalmars-d-learn
On Monday, 26 October 2020 at 14:31:00 UTC, Vino wrote: Hi All, Is it possible to create a multi dimensional associative array using mir.ndslice, if yes, (1): request you to point me to some example / docs (2): below is an example multi dimensional associative array using the core

Re: Is there something I'm not getting here?

2020-10-26 Thread matheus via Digitalmars-d-learn
On Tuesday, 27 October 2020 at 02:21:39 UTC, matheus wrote: On Tuesday, 27 October 2020 at 01:26:56 UTC, James Blachly wrote: On 10/26/20 9:19 PM, Ruby The Roobster wrote: Following code doesn't work(it's not the actual code but it represents it). Is there some rule about function overrides

Re: Is there something I'm not getting here?

2020-10-26 Thread matheus via Digitalmars-d-learn
On Tuesday, 27 October 2020 at 01:26:56 UTC, James Blachly wrote: On 10/26/20 9:19 PM, Ruby The Roobster wrote: Following code doesn't work(it's not the actual code but it represents it). Is there some rule about function overrides that I don't know about? ... The error I keep getting no

How is this an "Access Violation"

2020-10-26 Thread Ruby The Roobster via Digitalmars-d-learn
Following function when called throws an access violation. I think it has to do with the assert statements, but I don't know why. void construct(string type,atom base,atom bonded) { base = new

Re: Is there something I'm not getting here?

2020-10-26 Thread Ruby The Roobster via Digitalmars-d-learn
On Tuesday, 27 October 2020 at 01:19:58 UTC, Ruby The Roobster wrote: Following code doesn't work(it's not the actual code but it represents it). Is there some rule about function overrides that I don't know about? class a { public override string toString() { //... } } class b : a { public

Re: Is there something I'm not getting here?

2020-10-26 Thread James Blachly via Digitalmars-d-learn
On 10/26/20 9:19 PM, Ruby The Roobster wrote: Following code doesn't work(it's not the actual code but it represents it). Is there some rule about function overrides that I don't know about? ... The error I keep getting no matter what says: Error: Multiple Overrides of Same Function. Anybody

Is there something I'm not getting here?

2020-10-26 Thread Ruby The Roobster via Digitalmars-d-learn
Following code doesn't work(it's not the actual code but it represents it). Is there some rule about function overrides that I don't know about? class a { public override string toString() { //... } } class b : a { public override string toString() { //... } } The error I keep getting no

How Stop Worker Thread if Owner Thread is Finished?

2020-10-26 Thread Marcone via Digitalmars-d-learn
Because when the main thread is completed the worker thread continues to run.

Re: String Template Package

2020-10-26 Thread H. S. Teoh via Digitalmars-d-learn
On Mon, Oct 26, 2020 at 11:36:12PM +, Per Nordlöw via Digitalmars-d-learn wrote: > I need a string template system for generation of parsers in D code to > compiled in separate phase (not Pegged). > > What packages is there for this? Adela Vais is working on D support for GNU bison, a

String Template Package

2020-10-26 Thread Per Nordlöw via Digitalmars-d-learn
I need a string template system for generation of parsers in D code to compiled in separate phase (not Pegged). What packages is there for this?

C++ code to D (multi dem 3d mesh)

2020-10-26 Thread Joel via Digitalmars-d-learn
``` struct vec3d { float x, y, z; } struct triangle { vec3d[3] p; } struct mesh { triangle[] tris; } // This here meshCube.tris = { // SOUTH { 0.0f, 0.0f, 0.0f,0.0f, 1.0f, 0.0f,1.0f, 1.0f, 0.0f }, { 0.0f, 0.0f,

Re: Given a TypeInfo_Class, instance a new object of its type

2020-10-26 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 26 October 2020 at 21:57:18 UTC, Not A Rectangle wrote: Is this possible to do? Only if you know the type ahead of time, then you can cast it. Normally you'd probably just know an interface or base class it implements then you can cast to that, with the exact derived type being

Given a TypeInfo_Class, instance a new object of its type

2020-10-26 Thread Not A Rectangle via Digitalmars-d-learn
Hi everyone, Say i have a TypeInfo_Class representing a custom type, and i want a new instance of this class with its custom type, is there a way to do that? I am aware that TypeInfo_Class has the methods create() and factory(), both of which return a new object of the type Object. I have

Re: How can I use class and wasm?

2020-10-26 Thread Jack via Digitalmars-d-learn
On Friday, 16 October 2020 at 03:42:22 UTC, Adam D. Ruppe wrote: On Friday, 16 October 2020 at 03:04:25 UTC, Jack wrote: How can I allocate memory for this class? It is possible but not easy without druntime. If you are using -betterC, you can use extern(C++) classes with extern(D) members.

Foreach output into a multi dimensional associative array.

2020-10-26 Thread Vino via Digitalmars-d-learn
Hi All, Request your help on the below on how to store the output to a multi dimensional associative array. Code: import std.stdio: writeln; import asdf: parseJson; import std.conv: to; void main() { string[int][string] aa; string apidata = `{"items": [

Re: static alias this and if/do/while/for

2020-10-26 Thread Q. Schroll via Digitalmars-d-learn
On Thursday, 22 October 2020 at 21:55:59 UTC, Jack Applegame wrote: There is a funny feature (or bug) in the D language: static alias this and static operator overloading. For example interface Foo { static { int value; void opAssign(int v) { value = v; } int

Re: `unittest` placement in code?

2020-10-26 Thread Anonymouse via Digitalmars-d-learn
On Monday, 26 October 2020 at 13:16:32 UTC, Vladimirs Nordholm wrote: Hello. [...] Additionally, if you care about generating documentation, then placing them after whatever is being tested can make them end up as examples (of how to use them). Handy if your unittests shows how they're used

mir.ndslice : multi dimensional associative array - Example/Docs

2020-10-26 Thread Vino via Digitalmars-d-learn
Hi All, Is it possible to create a multi dimensional associative array using mir.ndslice, if yes, (1): request you to point me to some example / docs (2): below is an example multi dimensional associative array using the core d module, and how can we to implement the same

Re: `unittest` placement in code?

2020-10-26 Thread Vladimirs Nordholm via Digitalmars-d-learn
On Monday, 26 October 2020 at 13:36:58 UTC, Steven Schveighoffer wrote: On 10/26/20 9:16 AM, Vladimirs Nordholm wrote: [...] Wherever you want. Generally people put it right after the thing being tested to keep files organized. When the compiler runs unittests it runs them all in the

Re: `unittest` placement in code?

2020-10-26 Thread Steven Schveighoffer via Digitalmars-d-learn
On 10/26/20 9:16 AM, Vladimirs Nordholm wrote: Hello. I have a class which I have written some tests for, to ensure if I ever change some code it will still work as intended. The documentation https://dlang.org/spec/unittest.html says it is can be placed both in the class or outside it. I

Re: Can we do compile time reading part of a file using import?

2020-10-26 Thread Steven Schveighoffer via Digitalmars-d-learn
On 10/23/20 12:42 PM, data pulverizer wrote: Hi all, the `import` function allows a file to be read at compile time, which opens up great opportunities for (mostly binary) file IO, where data types can be coded into files - the user doesn't need to know data types ahead of time. As specified

Re: static alias this and if/do/while/for

2020-10-26 Thread Vladimirs Nordholm via Digitalmars-d-learn
On Thursday, 22 October 2020 at 21:55:59 UTC, Jack Applegame wrote: Now we can use type Foo as if it were an lvalue/rvalue: Foo = 5; int a = Foo; int b = Foo + a; Haha, that's pretty neat!

`unittest` placement in code?

2020-10-26 Thread Vladimirs Nordholm via Digitalmars-d-learn
Hello. I have a class which I have written some tests for, to ensure if I ever change some code it will still work as intended. The documentation https://dlang.org/spec/unittest.html says it is can be placed both in the class or outside it. I come from a background of having a completely

Re: this T / variadic template and interfaces

2020-10-26 Thread Jacob Carlborg via Digitalmars-d-learn
On Monday, 26 October 2020 at 11:14:47 UTC, frame wrote: Is there any way to get this working? I know, I could use a known object to feed the arguments and use that instead - but I want to keep things simple as possible. As Simen mentioned, templates cannot be virtual. But you don't need to

Re: Template pattern delegate?

2020-10-26 Thread frame via Digitalmars-d-learn
On Monday, 26 October 2020 at 09:25:03 UTC, Jacob Carlborg wrote: On Monday, 26 October 2020 at 00:56:26 UTC, frame wrote: If you pass the delegate as a template parameter/alias parameter, it's more likely to be inlined: auto myStuff(alias fn)() { try return fn(); catch (Exception

Re: this T / variadic template and interfaces

2020-10-26 Thread frame via Digitalmars-d-learn
On Monday, 26 October 2020 at 11:48:48 UTC, Simen Kjærås wrote: This makes sense if you consider that the user of the interface has no knowledge of the types that implement it, and vice versa: the implementing class has no idea which instantiations to make, and the user has no idea which

Re: this T / variadic template and interfaces

2020-10-26 Thread Simen Kjærås via Digitalmars-d-learn
On Monday, 26 October 2020 at 11:14:47 UTC, frame wrote: Did not find this topic: I have an interface and some wrapper classes that use it. The wrapper's methods should accept variadic arguments. The runtime should only work with the interface, trying casting to a wrapper is not an option,

this T / variadic template and interfaces

2020-10-26 Thread frame via Digitalmars-d-learn
Did not find this topic: I have an interface and some wrapper classes that use it. The wrapper's methods should accept variadic arguments. The runtime should only work with the interface, trying casting to a wrapper is not an option, because it's a plugin design. - defining a variadic

Re: Help on asdf json module

2020-10-26 Thread Vino via Digitalmars-d-learn
On Monday, 26 October 2020 at 09:43:44 UTC, Vino wrote: On Sunday, 25 October 2020 at 08:22:06 UTC, 9il wrote: [...] Hi All, Thank you for your help, and now need your suggestion as the below code is working and it also prints an additional value which is not expected, so request your

Re: Help on asdf json module

2020-10-26 Thread Vino via Digitalmars-d-learn
On Sunday, 25 October 2020 at 08:22:06 UTC, 9il wrote: On Sunday, 25 October 2020 at 06:05:27 UTC, Vino wrote: Hi All, Currently we are testing various json module such as "std.json, std_data_json, vibe.data.json and asdf", the below code works perfectely while use "std_data_json or

Re: Template pattern delegate?

2020-10-26 Thread Jacob Carlborg via Digitalmars-d-learn
On Monday, 26 October 2020 at 00:56:26 UTC, frame wrote: I see that your approach can handle functions and delegates but isn't that not equivalent like this template for a function? auto myStuff(T)(T function() fn) { try { return fn(); } catch (Exception e) { //

Re: Can we do compile time reading part of a file using import?

2020-10-26 Thread Jacob Carlborg via Digitalmars-d-learn
On Sunday, 25 October 2020 at 16:50:09 UTC, Jack wrote: Which build tool are you refering to? an existing one or build one oneself to do this job? It should work with any build tool that has hooks to execute arbitrary commands. -- /Jacob Carlborg