Re: modules and mains

2021-08-21 Thread Brian Tiffin via Digitalmars-d-learn
On Sunday, 22 August 2021 at 04:38:58 UTC, Ali Çehreli wrote: On 8/21/21 8:46 PM, Brian Tiffin wrote: > prompt$ cat B.d > module B; > version = boss; A cannot know about 'version' condition inside B. The solution is to provide version on the command line. This is how I do it with dmd: $ dmd

Re: std.stdio.File is throwing with the message of: "Access Violation"

2021-08-21 Thread evilrat via Digitalmars-d-learn
On Saturday, 21 August 2021 at 23:50:51 UTC, Ruby The Roobster wrote: On Saturday, 21 August 2021 at 23:50:08 UTC, Ruby The Roobster wrote: On Saturday, 21 August 2021 at 06:08:17 UTC, evilrat wrote: First parameter for CreateWindow should be window class string that you used in wndclass.lps

Re: implimenting interface function by inheriting from other class

2021-08-21 Thread Tejas via Digitalmars-d-learn
On Sunday, 22 August 2021 at 01:14:08 UTC, Alexey wrote: On Saturday, 21 August 2021 at 20:35:43 UTC, Alexey wrote: Hello ```D interface Int { void coolFunc(); } class C1 { void coolFunc() { return; } } class C2 : C1, Int { } void main() { auto c = new C2; } ``` d

Re: modules and mains

2021-08-21 Thread Ali Çehreli via Digitalmars-d-learn
On 8/21/21 8:46 PM, Brian Tiffin wrote: > prompt$ cat B.d > module B; > version = boss; A cannot know about 'version' condition inside B. The solution is to provide version on the command line. This is how I do it with dmd: $ dmd -version=boss [...] (So, remove 'version = boss;' line in B.d

Re: modules and mains

2021-08-21 Thread Brian Tiffin via Digitalmars-d-learn
On Sunday, 22 August 2021 at 03:22:02 UTC, Brian Tiffin wrote: Is this wrong thinking? I'm ~~working on~~ playing with a first project. Meant to be a suite of tools, each usable from the command line, i.e. with a `main`. Then a manager program that accepts subcommands for dispatch *and othe

modules and mains

2021-08-21 Thread Brian Tiffin via Digitalmars-d-learn
Is this wrong thinking? I'm ~~working on~~ playing with a first project. Meant to be a suite of tools, each usable from the command line, i.e. with a `main`. Then a manager program that accepts subcommands for dispatch *and other boss type things*. boss.d wants to import command1.d command

Re: Unqualified class name

2021-08-21 Thread jfondren via Digitalmars-d-learn
On Sunday, 22 August 2021 at 00:18:18 UTC, Ali Çehreli wrote: I did not read the linked thread but a "this template parameter" seems to work in this case: class Whoami { string name(this This)() const { return __traits(identifier, This); } } class AnotherOne : Whoami { } unittest { a

Re: implimenting interface function by inheriting from other class

2021-08-21 Thread Alexey via Digitalmars-d-learn
On Saturday, 21 August 2021 at 20:35:43 UTC, Alexey wrote: Hello ```D interface Int { void coolFunc(); } class C1 { void coolFunc() { return; } } class C2 : C1, Int { } void main() { auto c = new C2; } ``` dmd says it's not Ok: t.d(14): Error: class `t.C2` interfac

Re: Unqualified class name

2021-08-21 Thread Ali Çehreli via Digitalmars-d-learn
On 8/21/21 2:48 PM, jfondren wrote: On Saturday, 21 August 2021 at 21:13:58 UTC, Jeremy T. Gibson wrote: On Saturday, 21 August 2021 at 18:27:34 UTC, Ali Çehreli wrote:     return __traits(identifier, typeof(this)); That works perfectly!  Thanks. =) This is exactly the solution you linked t

Re: std.stdio.File is throwing with the message of: "Access Violation"

2021-08-21 Thread Adam D Ruppe via Digitalmars-d-learn
On Saturday, 21 August 2021 at 23:50:08 UTC, Ruby The Roobster wrote: wndclass.lpszClassName = "Test"; //May need casting... don't cast it just use the w suffix wndclass.lpszClassName = "Test"w; casts are usually indicating a mistake

Re: std.stdio.File is throwing with the message of: "Access Violation"

2021-08-21 Thread Ruby The Roobster via Digitalmars-d-learn
On Saturday, 21 August 2021 at 06:08:17 UTC, evilrat wrote: First parameter for CreateWindow should be window class string that you used in wndclass.lpszClassName = appName.toUTF16z; Fix: wndclass.lpszClassName = "Test"; //May need casting...

Re: std.stdio.File is throwing with the message of: "Access Violation"

2021-08-21 Thread Ruby The Roobster via Digitalmars-d-learn
On Saturday, 21 August 2021 at 23:50:08 UTC, Ruby The Roobster wrote: On Saturday, 21 August 2021 at 06:08:17 UTC, evilrat wrote: First parameter for CreateWindow should be window class string that you used in wndclass.lpszClassName = appName.toUTF16z; Fix: wndclass.lpszClassName = "Test";

Re: implimenting interface function by inheriting from other class

2021-08-21 Thread Alexey via Digitalmars-d-learn
On Saturday, 21 August 2021 at 23:14:14 UTC, Alexey wrote: I want `this` inside of C1::coolFunc to return C2 if called as C2::coolFunc so executing `cast(C2) this !is null` inside of C1::coolFunc would work If this would work, I'd farther used this like so ```D interface Int { void coolF

Re: implimenting interface function by inheriting from other class

2021-08-21 Thread Alexey via Digitalmars-d-learn
I want `this` inside of C1::coolFunc to return C2 if called as C2::coolFunc so executing `cast(C2) this !is null` inside of C1::coolFunc would work

Re: implimenting interface function by inheriting from other class

2021-08-21 Thread Alexey via Digitalmars-d-learn
On Saturday, 21 August 2021 at 22:56:40 UTC, Bastiaan Veelo wrote: On Saturday, 21 August 2021 at 20:35:43 UTC, Alexey wrote: Hello ```D interface Int { void coolFunc(); } class C1 { void coolFunc() { return; } } class C2 : C1, Int { } void main() { auto c = new C

Re: implimenting interface function by inheriting from other class

2021-08-21 Thread Bastiaan Veelo via Digitalmars-d-learn
On Saturday, 21 August 2021 at 20:35:43 UTC, Alexey wrote: Hello ```D interface Int { void coolFunc(); } class C1 { void coolFunc() { return; } } class C2 : C1, Int { } void main() { auto c = new C2; } ``` dmd says it's not Ok: t.d(14): Error: class `t.C2` interfac

Re: Unqualified class name

2021-08-21 Thread jfondren via Digitalmars-d-learn
On Saturday, 21 August 2021 at 21:13:58 UTC, Jeremy T. Gibson wrote: On Saturday, 21 August 2021 at 18:27:34 UTC, Ali Çehreli wrote: return __traits(identifier, typeof(this)); That works perfectly! Thanks. =) This is exactly the solution you linked to in your first post, and found want

Re: Unqualified class name

2021-08-21 Thread Jeremy T. Gibson via Digitalmars-d-learn
On Saturday, 21 August 2021 at 18:45:07 UTC, jfondren wrote: On Saturday, 21 August 2021 at 17:33:51 UTC, Jeremy T. Gibson wrote: is there a simple way to get the unqualified name of a class at runtime without having to pass it through std.format? `typeid(class).name` always yields the full cl

Re: Unqualified class name

2021-08-21 Thread Jeremy T. Gibson via Digitalmars-d-learn
On Saturday, 21 August 2021 at 18:27:34 UTC, Ali Çehreli wrote: return __traits(identifier, typeof(this)); That works perfectly! Thanks. =)

implimenting interface function by inheriting from other class

2021-08-21 Thread Alexey via Digitalmars-d-learn
Hello ```D interface Int { void coolFunc(); } class C1 { void coolFunc() { return; } } class C2 : C1, Int { } void main() { auto c = new C2; } ``` dmd says it's not Ok: t.d(14): Error: class `t.C2` interface function `void coolFunc()` is not implemented how to ma

Re: Unqualified class name

2021-08-21 Thread jfondren via Digitalmars-d-learn
On Saturday, 21 August 2021 at 17:33:51 UTC, Jeremy T. Gibson wrote: is there a simple way to get the unqualified name of a class at runtime without having to pass it through std.format? `typeid(class).name` always yields the full classname, including its module information (i.e., "modulename

Re: Unqualified class name

2021-08-21 Thread Ali Çehreli via Digitalmars-d-learn
On 8/21/21 10:33 AM, Jeremy T. Gibson wrote: `typeid(class).name` always yields the full classname, including its module information (i.e., "modulename.classname"), where I only want "classname" on its own. I've been reminded of __traits(identifier) on this forum just yesterday: import std.s

Unqualified class name

2021-08-21 Thread Jeremy T. Gibson via Digitalmars-d-learn
I saw this thread -- https://forum.dlang.org/post/hdkvezicxfvehbtvj...@forum.dlang.org -- which works at compile time (although templating seems like overkill for my purpose), but is there a simple way to get the unqualified name of a class at runtime without having to pass it through std.form

Re: Lexicographical object comparison by selected members of a struct

2021-08-21 Thread Tejas via Digitalmars-d-learn
On Saturday, 21 August 2021 at 13:45:59 UTC, Ali Çehreli wrote: On 8/21/21 1:31 AM, Tejas wrote: > I was more impressed that you found that hack in the first place I can't take credit. :) 'static foreach' had that difference since its inception. The spec says "If a new scope is desired for ea

Re: Lexicographical object comparison by selected members of a struct

2021-08-21 Thread Ali Çehreli via Digitalmars-d-learn
On 8/21/21 1:31 AM, Tejas wrote: > I was more impressed that you found that hack in the first place I can't take credit. :) 'static foreach' had that difference since its inception. The spec says "If a new scope is desired for each expansion, use another set of braces:" https://dlang.org/s

Re: C to D convertor

2021-08-21 Thread Виталий Фадеев via Digitalmars-d-learn
On Saturday, 21 August 2021 at 08:59:55 UTC, evilrat wrote: On Saturday, 21 August 2021 at 08:14:22 UTC, Виталий Фадеев wrote: I know, i know... It not possible, but part of the C code we can to convert to the D. Show me, please, solutions, projects, tools, scripts, docs. Can you give the link

Re: C to D convertor

2021-08-21 Thread evilrat via Digitalmars-d-learn
On Saturday, 21 August 2021 at 08:14:22 UTC, Виталий Фадеев wrote: I know, i know... It not possible, but part of the C code we can to convert to the D. Show me, please, solutions, projects, tools, scripts, docs. Can you give the link ? `htod` is 1. Any more ? dstep https://code.dlang.org/pac

Re: Lexicographical object comparison by selected members of a struct

2021-08-21 Thread Tejas via Digitalmars-d-learn
On Saturday, 21 August 2021 at 06:58:47 UTC, Ali Çehreli wrote: On 8/20/21 11:19 PM, Tejas wrote: [...] Yes. 'static foreach' does not introduce scope, which can be pretty useful. For example, one can define functions at module scope. The subtle differences between 'static foreach' and '(

C to D convertor

2021-08-21 Thread Виталий Фадеев via Digitalmars-d-learn
I know, i know... It not possible, but part of the C code we can to convert to the D. Show me, please, solutions, projects, tools, scripts, docs. Can you give the link ? Examples of what the wanted: // C typedef struct { uint32_t version; /* 0x5000 */ uin

Re: Lexicographical object comparison by selected members of a struct

2021-08-21 Thread Ali Çehreli via Digitalmars-d-learn
On 8/20/21 11:19 PM, Tejas wrote: On Saturday, 21 August 2021 at 06:03:33 UTC, Ali Çehreli wrote: On 8/20/21 10:37 PM, Alexandru Ermicioi wrote: [...] Cool! Much better. :) I could not do [...] Did you use that double curly bracket in `static foreach` so that you don't get error for decl