Re: What happened to Circular Studio?

2022-06-06 Thread Jack via Digitalmars-d-learn
for those that don't know: https://circularstudios.com/

What happened to Circular Studio?

2022-06-06 Thread Jack via Digitalmars-d-learn
I just found out a game using D to develop games but later I see the last updates on the github, web site, twitter etc is from 2015. Does anyone knows what happend to the company?

Re: Execute the Shell command and continue executing the algorithm

2022-05-31 Thread Jack via Digitalmars-d-learn
On Tuesday, 31 May 2022 at 15:29:16 UTC, frame wrote: On Monday, 30 May 2022 at 11:18:42 UTC, Alexander Zhirov wrote: if (here is my condition termination of the program) OT: Wouldn't it be great to have ArnoldC support? ;-) i'm pretty sure the terminattor is more efficient than kill

Re: UI Library

2022-05-27 Thread Jack via Digitalmars-d-learn
On Friday, 20 May 2022 at 12:32:37 UTC, ryuukk_ wrote: Avoid GTK, it's bloated, GTK4 looks like a toolkit to design mobile apps, and you need runtime dependencies on windows adam's gui library is very nice, 0 dependencies I personally prefer IMGUI, 0 dependencies, you bring the could you

Re: Faster Dlang Execution

2021-06-08 Thread Jack via Digitalmars-d-learn
On Tuesday, 8 June 2021 at 17:40:19 UTC, Basile B. wrote: On Tuesday, 8 June 2021 at 17:10:47 UTC, seany wrote: Hello How can I increase the speed of executable files created via : `dub build -b release` try `dub build -b release --compiler=ldc2` Then you can set some specific DFlags for

Re: how do i fix this node_dlang error?

2021-06-08 Thread Jack via Digitalmars-d-learn
On Tuesday, 8 June 2021 at 03:04:39 UTC, Mike Parker wrote: On Tuesday, 8 June 2021 at 00:58:12 UTC, Jack wrote: the dll which I was just build with dub command? how I have a version mismatch if they're the very same file? Electron embeds node and does not use whatever you have on your

Re: how do i fix this node_dlang error?

2021-06-08 Thread Jack via Digitalmars-d-learn
On Tuesday, 8 June 2021 at 04:56:27 UTC, NotSpooky wrote: On Tuesday, 8 June 2021 at 03:04:39 UTC, Mike Parker wrote: On Tuesday, 8 June 2021 at 00:58:12 UTC, Jack wrote: [...] Electron embeds node and does not use whatever you have on your system. So if there’s a mismatch between the

Re: how to enable safeD ? dmd.conf ? dmd switch ?

2021-06-07 Thread Jack via Digitalmars-d-learn
On Tuesday, 8 June 2021 at 03:32:31 UTC, someone wrote: On Tuesday, 8 June 2021 at 02:59:28 UTC, rikki cattermole wrote: SafeD is an old name given to the attributes @safe @trusted @system. I have the Alexandrescu's book on hand so that explains it. There is no switch nor any special

Re: how do i fix this node_dlang error?

2021-06-07 Thread Jack via Digitalmars-d-learn
On Tuesday, 8 June 2021 at 00:00:50 UTC, Mike Parker wrote: On Monday, 7 June 2021 at 22:24:03 UTC, Jack wrote: I think the entry point function is ```void atStart(napi_env env) {}``` so there's no DllMain... DLLMain is not strictly required. It's called by the system loader when the DLL

Re: how do i fix this node_dlang error?

2021-06-07 Thread Jack via Digitalmars-d-learn
On Monday, 7 June 2021 at 20:37:19 UTC, MoonlightSentinel wrote: On Monday, 7 June 2021 at 19:03:44 UTC, Jack wrote: actually i didnt so I just added: ```d shared static this() { Runtime.initialize(); } shared static ~this() { Runtime.terminate(); } ``` but it didn't change

Re: how do i fix this node_dlang error?

2021-06-07 Thread Jack via Digitalmars-d-learn
On Monday, 7 June 2021 at 20:13:03 UTC, frame wrote: On Monday, 7 June 2021 at 02:33:38 UTC, Jack wrote: What am I missing? If this runs under Windows, there is no dlopen(), maybe a wrapper to LoadLibrary() but this will need to call a DllMain() in the DLL if I am not wrong. Is there a

Re: how do i fix this node_dlang error?

2021-06-07 Thread Jack via Digitalmars-d-learn
On Monday, 7 June 2021 at 20:13:03 UTC, frame wrote: On Monday, 7 June 2021 at 02:33:38 UTC, Jack wrote: What am I missing? If this runs under Windows, there is no dlopen(), maybe a wrapper to LoadLibrary() but this will need to call a DllMain() in the DLL if I am not wrong. Is there a

Re: how do i fix this node_dlang error?

2021-06-07 Thread Jack via Digitalmars-d-learn
On Monday, 7 June 2021 at 17:22:48 UTC, MoonlightSentinel wrote: On Monday, 7 June 2021 at 02:33:38 UTC, Jack wrote: What am I missing? Does your code / `node_dlang` initialize Druntime before calling `writeln`? actually i didnt so I just added: ```d shared static this() {

Re: is it possible to have a default property for any given class ?

2021-06-07 Thread Jack via Digitalmars-d-learn
On Monday, 7 June 2021 at 15:26:27 UTC, someone wrote: Consider the following code: ```d class classComputer { private string pstrName; final @property string name() { return this.pstrName; } final @property void name(in string lstrName) { this.pstrName = lstrName; } this(

Re: how do i fix this node_dlang error?

2021-06-06 Thread Jack via Digitalmars-d-learn
On Sunday, 6 June 2021 at 21:44:44 UTC, NotSpooky wrote: On Sunday, 6 June 2021 at 04:25:39 UTC, Jack wrote: I'm trying to use the node_dlang pakckage but the code example from [this repo](https://github.com/NotSpooky/node_dlang/tree/v0.4.11/examples) isn't working the command ```dub

Re: how do i fix this node_dlang error?

2021-06-06 Thread Jack via Digitalmars-d-learn
On Sunday, 6 June 2021 at 17:32:57 UTC, Mike Parker wrote: On Sunday, 6 June 2021 at 15:42:55 UTC, Jack wrote: 0.4.11\node_dlang\source\node_dlang.d(137,11): Error: none of the overloads of `this` are callable using argument types `(string, string, ulong, Throwable)`, candidates are: [...]

Re: how do i fix this node_dlang error?

2021-06-06 Thread Jack via Digitalmars-d-learn
On Sunday, 6 June 2021 at 06:10:18 UTC, Mike Parker wrote: On Sunday, 6 June 2021 at 04:25:39 UTC, Jack wrote: I'm trying to use the node_dlang pakckage but the code example from [this repo](https://github.com/NotSpooky/node_dlang/tree/v0.4.11/examples) isn't working the command ```dub

Re: how do i fix this node_dlang error?

2021-06-06 Thread Jack via Digitalmars-d-learn
On Sunday, 6 June 2021 at 06:10:18 UTC, Mike Parker wrote: On Sunday, 6 June 2021 at 04:25:39 UTC, Jack wrote: I'm trying to use the node_dlang pakckage but the code example from [this repo](https://github.com/NotSpooky/node_dlang/tree/v0.4.11/examples) isn't working the command ```dub

how do i fix this node_dlang error?

2021-06-05 Thread Jack via Digitalmars-d-learn
I'm trying to use the node_dlang pakckage but the code example from [this repo](https://github.com/NotSpooky/node_dlang/tree/v0.4.11/examples) isn't working the command ```dub build``` is fine but ```node example.js``` retuns an error saying the module.node is not a valid win32 application.

Re: Working with ranges

2021-05-26 Thread Jack via Digitalmars-d-learn
On Wednesday, 26 May 2021 at 13:58:56 UTC, Elmar wrote: On Saturday, 8 December 2018 at 03:51:02 UTC, Adam D. Ruppe wrote: [...] That's amazing, this should be one thing that should appear in every tutorial just right at the start! I was looking hours for a way to generate an "iterator" (a

Re: Template and alloca?

2021-05-26 Thread Jack via Digitalmars-d-learn
On Wednesday, 26 May 2021 at 11:31:31 UTC, Ola Fosheim Grostad wrote: On Wednesday, 26 May 2021 at 08:38:29 UTC, Imperatorn wrote: On Wednesday, 26 May 2021 at 07:34:06 UTC, Ola Fosheim Grøstad wrote: On Tuesday, 25 May 2021 at 17:55:17 UTC, Ola Fosheim Grostad wrote: Is it possible to use a

Re: DMC + Win32Api: Error: undefined identifier 'SetDCBrushColor'

2021-05-16 Thread Jack via Digitalmars-d-learn
On Sunday, 16 May 2021 at 14:51:56 UTC, Marcone wrote: Well, I program in D as a hobby for just over a year, and I like to learn and explore this wonderful programming language. Now I found the DMC compiler that compiles C ++ code. So I decided to test it. Creating a program with a win32api

Re: how do I implement opSlice for retro range?

2021-05-14 Thread Jack via Digitalmars-d-learn
On Friday, 14 May 2021 at 14:14:03 UTC, Steven Schveighoffer wrote: On 5/13/21 11:49 PM, Jack wrote: [...] Just slice the `a`, appropriately. You have to translate the indexes back into the original array. ```d auto opSlice(size_t start, size_t end) { return typeof(this)(a[$ - end .. $ -

Re: how do I implement opSlice for retro range?

2021-05-14 Thread Jack via Digitalmars-d-learn
On Friday, 14 May 2021 at 10:00:44 UTC, Christian Köstlin wrote: On 2021-05-14 05:49, Jack wrote: [...] arr.retro()[0..2] already works. see https://run.dlang.io/is/U8u3br oh, how i silly of i didn't notice that before

Re: how do I implement opSlice for retro range?

2021-05-13 Thread Jack via Digitalmars-d-learn
sorry, in this code i mean b must be [5, 4] ```d auto arr = [1, 2, 3, 4, 5]; auto a = new A!int(arr); auto b = a.retro[0 .. 2]; //5,4 ```

how do I implement opSlice for retro range?

2021-05-13 Thread Jack via Digitalmars-d-learn
How can I implement ranges in the retro range? I'd like to do this without allocate a new array with .array from std.array, can I do that? use like this: ```d auto arr = [1, 2, 3, 4, 5]; auto a = new A!int(arr); auto b = a.retro[0 .. 2]; // 4, 5 ``` the class: ```d class A(T) {

cannot I override and mark it as private?

2021-05-12 Thread Jack via Digitalmars-d-learn
I'd to change the visibility of a method overrided from public to private but it doesn't work tho to protected it does. Why is that? give: ```d class A { void f() { } } ``` this is ok: ```d class B : A { protected override void f() { } } ``` this is not: ```d class B : A {

Re: can I reuse statements?

2021-05-10 Thread Jack via Digitalmars-d-learn
On Monday, 10 May 2021 at 21:10:13 UTC, Paul Backus wrote: On Monday, 10 May 2021 at 21:01:53 UTC, Jack wrote: [...] You can do it with a string mixin: ```d // Note: q{ ... } creates a "token string", a special kind of string literal // that's used for code strings. // See

can I reuse statements?

2021-05-10 Thread Jack via Digitalmars-d-learn
mixin template seems to allow only declarations so if I put a if or case-statement in the body it doesn't work. I'd like to make something like this work: ```d switch(code) { case X, Y: // that specific case repeats alot in the code in different procedures

Without multiples inheritance, how is this done?

2021-05-08 Thread Jack via Digitalmars-d-learn
let's say I have: ```d class Base { int f() { doSomething(); return n * 5; } void doSomething() { } } class Foo : Base { void myMethod() { /* ... */ } } class Baa : Base { void myMethod2() { /* ... */ } } ``` then I'd like to make a extended

Re: What does @nogc do to a class?

2021-05-08 Thread Jack via Digitalmars-d-learn
On Thursday, 6 May 2021 at 22:16:04 UTC, Per Nordlöw wrote: On Thursday, 6 May 2021 at 01:04:02 UTC, Jack wrote: Does it allocate the object rather on stack, like auto scope a = new A or what? Further note that auto scope a = new A; can be written shorter as scope a = new A; I'll

Re: What does @nogc do to a class?

2021-05-06 Thread Jack via Digitalmars-d-learn
On Thursday, 6 May 2021 at 02:11:27 UTC, Mike Parker wrote: On Thursday, 6 May 2021 at 01:04:02 UTC, Jack wrote: Does it allocate the object rather on stack, like auto scope a = new A or what? It doesn't do anything to classes. `@nogc` prevents you from any action triggers a GC allocation,

What does @nogc do to a class?

2021-05-05 Thread Jack via Digitalmars-d-learn
Does it allocate the object rather on stack, like auto scope a = new A or what?

What's a good approach to DRY with the block code of a case-statement?

2021-04-26 Thread Jack via Digitalmars-d-learn
I have a block of code that the only thing that change is the type passed in one of the template functions called so I'd like to make a DRY for this. But I'm not just replacing by a function due to control-flow, for example, there are if-statements where one just break and the other return 0.

Re: write once type?

2021-04-25 Thread Jack via Digitalmars-d-learn
On Tuesday, 20 April 2021 at 19:56:33 UTC, Steven Schveighoffer wrote: I have had the need in some cases to *maybe* set a const value inside a loop. One can sometimes abstract this into a lambda function, but sometimes this is not possible (e.g. if the loop is static). Not only that, but I may

Re: get type name from current class at compile time?

2021-04-25 Thread Jack via Digitalmars-d-learn
On Sunday, 25 April 2021 at 08:36:51 UTC, Adam D. Ruppe wrote: On Sunday, 25 April 2021 at 03:45:13 UTC, Jack wrote: that's better, thanks Imporant to remember that any compile time thing will be the static type. If someone does: Base a = new Derived(); a.something(); it will still show

Re: get type name from current class at compile time?

2021-04-24 Thread Jack via Digitalmars-d-learn
On Sunday, 25 April 2021 at 02:45:38 UTC, Paul Backus wrote: On Sunday, 25 April 2021 at 02:26:00 UTC, Jack wrote: doesn't this work when called from member in a derived class? ```d class A { void doSomething(this T)() { writefln("name = [%s]",

Re: get type name from current class at compile time?

2021-04-24 Thread Jack via Digitalmars-d-learn
On Sunday, 25 April 2021 at 02:26:00 UTC, Jack wrote: On Sunday, 25 April 2021 at 02:02:47 UTC, Ali Çehreli wrote: On 4/24/21 6:50 PM, Jack wrote: I'd like to output `K` and get this identifier at compile time. This is solved by the "this template parameter": import std.stdio; class A {

Re: get type name from current class at compile time?

2021-04-24 Thread Jack via Digitalmars-d-learn
On Sunday, 25 April 2021 at 02:02:47 UTC, Ali Çehreli wrote: On 4/24/21 6:50 PM, Jack wrote: I'd like to output `K` and get this identifier at compile time. This is solved by the "this template parameter": import std.stdio; class A { void showMyName(this T)() { writefln("name = [%s]",

Re: get type name from current class at compile time?

2021-04-24 Thread Jack via Digitalmars-d-learn
On Sunday, 25 April 2021 at 02:02:47 UTC, Ali Çehreli wrote: On 4/24/21 6:50 PM, Jack wrote: I'd like to output `K` and get this identifier at compile time. This is solved by the "this template parameter": import std.stdio; class A { void showMyName(this T)() { writefln("name = [%s]",

Re: Can I rely on format returned by fullyQualifiedName?

2021-04-24 Thread Jack via Digitalmars-d-learn
On Saturday, 24 April 2021 at 04:09:15 UTC, Mike Parker wrote: On Saturday, 24 April 2021 at 03:40:20 UTC, Jack wrote: Can I rely on this format from fullyQualifiedName? for example, let's say I do: ```d enum s = fullyQualifiedName!f.split; ``` where f is a function member of a class. Can I

get type name from current class at compile time?

2021-04-24 Thread Jack via Digitalmars-d-learn
```d class A { void showMyName() { writefln("name = [%s]", __traits(identifier, typeof(this))); } } class K : A { } ``` then ```d new K().showMyName(); ``` output: name = [A] I'd like to output `K` and get this identifier at compile time. But I'd to

Can I rely on format returned by fullyQualifiedName?

2021-04-23 Thread Jack via Digitalmars-d-learn
Can I rely on this format from fullyQualifiedName? for example, let's say I do: ```d enum s = fullyQualifiedName!f.split; ``` where f is a function member of a class. Can I realy that s[0] is the module name, s[1] is the class name and s[2] the functio name? is this standard or can the

How to implement a range?

2021-04-16 Thread Jack via Digitalmars-d-learn
In order to my array class work with filter, I went to implement an ``InputRange``. But I don't quite get how do that and didn't find much help on the docs. From below code, is ``moveFront()`` implemented correctly? I'm using a simple int i as index of current item and in popFront() just

Re: How do I create classes dynamically?

2021-04-15 Thread Jack via Digitalmars-d-learn
On Thursday, 15 April 2021 at 17:48:02 UTC, Imperatorn wrote: On Thursday, 15 April 2021 at 16:39:30 UTC, Kagamin wrote: On Wednesday, 14 April 2021 at 20:38:16 UTC, Mario wrote: [...] String mixins is D replacement of macros for code generation. Works like this: ```d mixin("class

Re: "this" as default parameter for a constructor.

2021-04-12 Thread Jack via Digitalmars-d-learn
On Sunday, 11 April 2021 at 20:38:10 UTC, Pierre wrote: Hi, I have a class with a reference to the parent object and a constructor that has the parent as parameter class foo { this ( foo p /* , other params */ ) { parent = p; } foo parent; } Of

How to allow +=, -=, etc operators and keep encapsulation?

2021-04-12 Thread Jack via Digitalmars-d-learn
Give this class: ```d class A { int X() { return x; } int X(int v) { return x = v;} private int x; } ``` I'd like to allow use ```+=```, ```-=``` operators on ```X()``` and keep encapsulation. What's a somehow elegant way to do that?

Re: Is there a more elegant way to do this in D?

2021-04-08 Thread Jack via Digitalmars-d-learn
On Thursday, 8 April 2021 at 16:45:14 UTC, Jack wrote: On Thursday, 8 April 2021 at 04:02:26 UTC, Ali Çehreli wrote: On 4/7/21 8:57 PM, Brad wrote:     auto a = [1,0,1,1,1,0,1,0,1,1,1,1,0]; I want to come out of this with a string that looks like this: 101110100 Me, me, me, me! :)

Re: Is there a more elegant way to do this in D?

2021-04-08 Thread Jack via Digitalmars-d-learn
On Thursday, 8 April 2021 at 04:02:26 UTC, Ali Çehreli wrote: On 4/7/21 8:57 PM, Brad wrote:     auto a = [1,0,1,1,1,0,1,0,1,1,1,1,0]; I want to come out of this with a string that looks like this: 101110100 Me, me, me, me! :) import std; void main() { auto a =

Re: How to update terminal output?

2021-03-28 Thread Jack via Digitalmars-d-learn
On Sunday, 28 March 2021 at 16:45:29 UTC, dog2002 wrote: I mean, I want to write a string without a new line. For example, some command line applications have progress bars. For a single line string I use \r. But it doesn't work for a multiple line string - the application is just adding new

Re: How can I allocate a int[] array on stack?

2021-03-26 Thread Jack via Digitalmars-d-learn
On Friday, 26 March 2021 at 06:45:39 UTC, Daniel Kozak wrote: On Fri, Mar 26, 2021 at 7:36 AM Daniel Kozak wrote: On Fri, Mar 26, 2021 at 7:31 AM Daniel Kozak wrote: On Fri, Mar 26, 2021 at 6:50 AM Jack via Digitalmars-d-learn < digitalmars-d-learn@puremagic.com> wrote:

How can I allocate a int[] array on stack?

2021-03-25 Thread Jack via Digitalmars-d-learn
What's the equivalent of C's VLA in D? scoped from std.typecons doesn't seem to work with arrays. Should I use alloca() for my array or is there something else?

Re: Using onOutOfMemoryError in C wrappers

2021-03-24 Thread Jack via Digitalmars-d-learn
On Wednesday, 24 March 2021 at 08:31:19 UTC, Basile B. wrote: On Wednesday, 24 March 2021 at 07:58:22 UTC, Per Nordlöw wrote: When wrapping C code that tries to allocate memory resources via functions such as X* X_create(); should one call `onOutOfMemoryError();` upon null return?

Re: How do I check if this field is of this template struct?

2021-03-20 Thread Jack via Digitalmars-d-learn
On Saturday, 20 March 2021 at 00:16:06 UTC, Steven Schveighoffer wrote: On 3/19/21 12:41 PM, Jack wrote: On Friday, 19 March 2021 at 08:54:50 UTC, Paul Backus wrote: On Friday, 19 March 2021 at 07:14:46 UTC, Jack wrote: give below template struct, how can I list the members x, y and z? I've

Re: How do I check if this field is of this template struct?

2021-03-19 Thread Jack via Digitalmars-d-learn
On Friday, 19 March 2021 at 17:40:39 UTC, frame wrote: On Friday, 19 March 2021 at 16:41:11 UTC, Jack wrote: thanks this works fine outside a method but not in a static method. what am I missing? Reading the manual ;) To use isInstanceOf to check the identity of a template while inside of

Can I make this work?

2021-03-19 Thread Jack via Digitalmars-d-learn
there's a value passed as template parameter which is know at compile time (can be used with static if) but I don't know how can I pass it around and use in a property. Obviously enum deosn't work because it would be a local to the function. immutable would result in compiler can't read it at

Re: How do I check if this field is of this template struct?

2021-03-19 Thread Jack via Digitalmars-d-learn
On Friday, 19 March 2021 at 08:54:50 UTC, Paul Backus wrote: On Friday, 19 March 2021 at 07:14:46 UTC, Jack wrote: give below template struct, how can I list the members x, y and z? I've tried something with OriginalType and TemplateOf but no luck... it seems if I do foo!"str1" the "str1"

Re: How do I check if this field is of this template struct?

2021-03-19 Thread Jack via Digitalmars-d-learn
On Friday, 19 March 2021 at 07:56:26 UTC, Panke wrote: On Friday, 19 March 2021 at 07:14:46 UTC, Jack wrote: give below template struct, how can I list the members x, y and z? I've tried something with OriginalType and TemplateOf but no luck... it seems if I do foo!"str1" the "str1" became

How do I check if this field is of this template struct?

2021-03-19 Thread Jack via Digitalmars-d-learn
give below template struct, how can I list the members x, y and z? I've tried something with OriginalType and TemplateOf but no luck... it seems if I do foo!"str1" the "str1" became "part of type"? give .stringof from typeof(__traits(getMember, foo, field)) I thought the type would be

question about ref keyword

2021-03-18 Thread Jack via Digitalmars-d-learn
let's assume this class: class C { private S m_s; this() { m_s = S(30); } ref S value() { return m_s; } ref S value(ref S s) { return m_s = s; } } and I do something like this: auto s1 =

Re: How to change button text color in NM_CUSTOMDRAW (Win32 API question)

2021-03-16 Thread Jack via Digitalmars-d-learn
On Tuesday, 16 March 2021 at 17:26:01 UTC, Vinod K Chandran wrote: Hi all, I am creating a Button class with Win32 API functions. So far so good. I am using NM_CUSTOMDRAW message to change the back color of my buttons. It's really easy to change the back color in this way. But I can't change

Re: Make foreach element optional

2021-03-16 Thread Jack via Digitalmars-d-learn
On Tuesday, 16 March 2021 at 15:02:54 UTC, Steven Schveighoffer wrote: On 3/16/21 8:49 AM, Per Nordlöw wrote: I find myself writing foreach (_; 0 .. n)     doSomething(); // no using the variable `_` . What about relaxing the syntax to allow     foreach (; 0 .. n) and/or     foreach (0

Re: How can I make this work?

2021-03-16 Thread Jack via Digitalmars-d-learn
On Tuesday, 16 March 2021 at 16:02:14 UTC, Vinod K Chandran wrote: On Sunday, 28 February 2021 at 13:15:47 UTC, Adam D. Ruppe wrote: And it is the simplest thing, no missing length, no weird property casting. The GC handled with two simple add/remove calls. Perfect example of teaching

Re: How can I make this work?

2021-03-16 Thread Jack via Digitalmars-d-learn
On Sunday, 28 February 2021 at 13:15:47 UTC, Adam D. Ruppe wrote: On Sunday, 28 February 2021 at 07:05:27 UTC, Jack wrote: I'm using a windows callback function where the user-defined value is passed thought a LPARAM argument type. I'd like to pass my D array then access it from that callback

Re: Can't I allocate at descontructor?

2021-03-05 Thread Jack via Digitalmars-d-learn
On Friday, 5 March 2021 at 21:24:08 UTC, tsbockman wrote: On Friday, 5 March 2021 at 21:17:24 UTC, tsbockman wrote: On Friday, 5 March 2021 at 21:02:08 UTC, H. S. Teoh wrote: class C {...} import core.memory : GC; C c = cast(C) GC.malloc(C.sizeof); ... ...

Re: Can't I allocate at descontructor?

2021-03-05 Thread Jack via Digitalmars-d-learn
On Friday, 5 March 2021 at 21:25:52 UTC, Ali Çehreli wrote: On 3/5/21 12:57 PM, Jack wrote: >> destroy() executes the destructor. > > but I would need to call it manually and only after I somewhat I've > determined I no longer need the resources, right? so destroy(c) would be > no different

Re: Can't I allocate at descontructor?

2021-03-05 Thread Jack via Digitalmars-d-learn
On Friday, 5 March 2021 at 21:02:08 UTC, H. S. Teoh wrote: On Fri, Mar 05, 2021 at 08:24:26PM +, Jack via Digitalmars-d-learn wrote: On Friday, 5 March 2021 at 20:18:44 UTC, Max Haughton wrote: > On Friday, 5 March 2021 at 20:13:54 UTC, Jack wrote: [...] > > But the ones heap

Re: Can't I allocate at descontructor?

2021-03-05 Thread Jack via Digitalmars-d-learn
On Friday, 5 March 2021 at 20:28:58 UTC, Ali Çehreli wrote: On 3/5/21 12:24 PM, Jack wrote: Are there some kind of replacement or I have to make my own finalize-like method, once I determine somewhat the application no longer need those resources? destroy() executes the destructor. but I

Re: Can't I allocate at descontructor?

2021-03-05 Thread Jack via Digitalmars-d-learn
On Friday, 5 March 2021 at 20:18:44 UTC, Max Haughton wrote: On Friday, 5 March 2021 at 20:13:54 UTC, Jack wrote: On Friday, 5 March 2021 at 20:10:39 UTC, Max Haughton wrote: On Friday, 5 March 2021 at 20:03:58 UTC, Jack wrote: On Friday, 5 March 2021 at 09:23:29 UTC, Mike Parker wrote: On

Re: Can't I allocate at descontructor?

2021-03-05 Thread Jack via Digitalmars-d-learn
On Friday, 5 March 2021 at 20:10:39 UTC, Max Haughton wrote: On Friday, 5 March 2021 at 20:03:58 UTC, Jack wrote: On Friday, 5 March 2021 at 09:23:29 UTC, Mike Parker wrote: On Friday, 5 March 2021 at 05:31:38 UTC, Jack wrote: The following code returns a memory error. I did notice it did

Re: Can't I allocate at descontructor?

2021-03-05 Thread Jack via Digitalmars-d-learn
On Friday, 5 March 2021 at 09:23:29 UTC, Mike Parker wrote: On Friday, 5 March 2021 at 05:31:38 UTC, Jack wrote: The following code returns a memory error. I did notice it did happens whenever I did a memory allocation. Is this not possible in the descontrutor? if so, why?

Re: Can't I allocate at descontructor?

2021-03-05 Thread Jack via Digitalmars-d-learn
On Friday, 5 March 2021 at 05:42:03 UTC, evilrat wrote: On Friday, 5 March 2021 at 05:31:38 UTC, Jack wrote: The following code returns a memory error. I did notice it did happens whenever I did a memory allocation. Is this not possible in the descontrutor? if so, why? GC prohibits

Re: Is there any generic iteration function that stops at first match?

2021-03-04 Thread Jack via Digitalmars-d-learn
On Friday, 5 March 2021 at 04:22:23 UTC, Steven Schveighoffer wrote: On Friday, 5 March 2021 at 02:13:39 UTC, Jack wrote: something like filter[1] but that stops at first match? are there any native functions for this in D or I have to write one? just making sure to not reinvent the wheel

Re: Is there any generic iteration function that stops at first match?

2021-03-04 Thread Jack via Digitalmars-d-learn
On Friday, 5 March 2021 at 02:43:36 UTC, H. S. Teoh wrote: On Fri, Mar 05, 2021 at 02:13:39AM +, Jack via Digitalmars-d-learn wrote: something like filter[1] but that stops at first match? are there any native functions for this in D or I have to write one? just making sure to not reinvent

Can't I allocate at descontructor?

2021-03-04 Thread Jack via Digitalmars-d-learn
The following code returns a memory error. I did notice it did happens whenever I did a memory allocation. Is this not possible in the descontrutor? if so, why? core.exception.InvalidMemoryOperationError@src\core\exception.d(647): Invalid memory operation import std.stdio; int main() {

Is there any generic iteration function that stops at first match?

2021-03-04 Thread Jack via Digitalmars-d-learn
something like filter[1] but that stops at first match? are there any native functions for this in D or I have to write one? just making sure to not reinvent the wheel [1]: https://devdocs.io/d/std_algorithm_iteration#filter

What's the default implementation of opCmp/opEquals for structs?

2021-03-03 Thread Jack via Digitalmars-d-learn
the one that the compiler defaults to when you don't provide one?

How can I tell if the give parameter can be run at compile time?

2021-03-01 Thread Jack via Digitalmars-d-learn
bool g(T)(T) { return __traits(compiles, mixin("{ enum a = t; }")); } int a; enum s = ""; // both return false but g(s) is expected to return true pragma(msg, g(s)); pragma(msg, g(a));

Re: Does reserve() preallocate for futher appends too?

2021-02-28 Thread Jack via Digitalmars-d-learn
On Monday, 1 March 2021 at 03:12:42 UTC, Adam D. Ruppe wrote: On Monday, 1 March 2021 at 03:07:19 UTC, Jack wrote: isn't clear for me if reserve() does preallocate memory so that that operator like arr ~= x can use previously allocate memory by reserve() or it's just used in slices like b =

Does reserve() preallocate for futher appends too?

2021-02-28 Thread Jack via Digitalmars-d-learn
isn't clear for me if reserve() does preallocate memory so that that operator like arr ~= x can use previously allocate memory by reserve() or it's just used in slices like b = arr[x .. y]?

Re: How do I check if a type is assignable to null at compile time?

2021-02-28 Thread Jack via Digitalmars-d-learn
On Saturday, 27 February 2021 at 01:23:06 UTC, H. S. Teoh wrote: On Sat, Feb 27, 2021 at 01:03:56AM +, Jack via Digitalmars-d-learn wrote: On Friday, 26 February 2021 at 23:37:18 UTC, Murilo wrote: > On Friday, 26 February 2021 at 05:25:14 UTC, Jack wrote: > > I started with: >

How can I make this work?

2021-02-27 Thread Jack via Digitalmars-d-learn
I'm using a windows callback function where the user-defined value is passed thought a LPARAM argument type. I'd like to pass my D array then access it from that callback function. How is the casting from LPARAM to my type array done in that case? for example, I need something like this to

Re: How do I check if a type is assignable to null at compile time?

2021-02-26 Thread Jack via Digitalmars-d-learn
On Friday, 26 February 2021 at 23:37:18 UTC, Murilo wrote: On Friday, 26 February 2021 at 05:25:14 UTC, Jack wrote: I started with: enum isAssignableNull(T) = is(T : Object) || isPointer(T); but how do I cover all cases? You can check if it's null with this `variable is null` and you can

Re: How can I get the variable name passed as parameter from within a function?

2021-02-26 Thread Jack via Digitalmars-d-learn
On Friday, 26 February 2021 at 19:37:34 UTC, Adam D. Ruppe wrote: On Friday, 26 February 2021 at 19:32:52 UTC, Jack wrote: I managed to do this with alias parameter in a template: this is the only way, it needs to be an alias template Also, can I short this template function somehow to

How can I get the variable name passed as parameter from within a function?

2021-02-26 Thread Jack via Digitalmars-d-learn
int a = 10; f(a); // print "a" int b = 10; f(b); // print "b" I managed to do this with alias parameter in a template: template f(alias s, string file = __FILE__, size_t line = __LINE__) { import std.exception : enforce; import std.string : format; void g() {

Re: How do I check if a type is assignable to null at compile time?

2021-02-26 Thread Jack via Digitalmars-d-learn
On Friday, 26 February 2021 at 05:45:39 UTC, Nathan S. wrote: On Friday, 26 February 2021 at 05:34:26 UTC, Paul Backus wrote: On Friday, 26 February 2021 at 05:25:14 UTC, Jack wrote: I started with: enum isAssignableNull(T) = is(T : Object) || isPointer(T); but how do I cover all cases?

How do I check if a type is assignable to null at compile time?

2021-02-25 Thread Jack via Digitalmars-d-learn
I started with: enum isAssignableNull(T) = is(T : Object) || isPointer(T); but how do I cover all cases?

Is this a good way to do lazy evaluation?

2021-02-22 Thread Jack via Digitalmars-d-learn
I have a base class that loads a value and if it isn't net, load a default value. Since the value can be set, I'd like to do lazy evaluation of this default value until it's really needed. So rather have a C defValue = xxx, that makes xxx to be loaded even if defValue doesn't get used. So I

Re: Is this the proper way to do it?

2021-02-22 Thread Jack via Digitalmars-d-learn
On Saturday, 13 February 2021 at 07:08:58 UTC, mw wrote: On Saturday, 13 February 2021 at 05:52:34 UTC, Jack wrote: I have a base class A, where I make specific operator depending on the derived class type. Currently I'm using something like this: c is a class derived from A bool shouldDoX =

Re: Is this the proper way to do it?

2021-02-22 Thread Jack via Digitalmars-d-learn
On Saturday, 13 February 2021 at 19:40:43 UTC, frame wrote: On Saturday, 13 February 2021 at 05:52:34 UTC, Jack wrote: I have a base class A, where I make specific operator depending on the derived class type. Currently I'm using something like this: c is a class derived from A bool

Re: Is this the proper way to do it?

2021-02-22 Thread Jack via Digitalmars-d-learn
On Saturday, 13 February 2021 at 09:54:28 UTC, Rumbu wrote: On Saturday, 13 February 2021 at 05:52:34 UTC, Jack wrote: I have a base class A, where I make specific operator depending on the derived class type. Currently I'm using something like this: c is a class derived from A bool

Re: how to make this function nothrow?

2021-02-22 Thread Jack via Digitalmars-d-learn
On Tuesday, 16 February 2021 at 00:39:33 UTC, Steven Schveighoffer wrote: On 2/15/21 4:04 PM, Jack wrote: I have to make my function nothrow because the function that calls it (not written by me) is nothrow. So I need to wrap my code in a try-catch() but how will I report the error message,

Re: Foo Foo = new Foo();

2021-02-21 Thread Jack via Digitalmars-d-learn
Why doesn't this compiles? class Baa { Foo Foo = new Foo(); }

Re: How can I get this UDA at compile time?

2021-02-21 Thread Jack via Digitalmars-d-learn
On Sunday, 21 February 2021 at 09:30:14 UTC, Jacob Carlborg wrote: On 2021-02-21 07:12, Jack wrote: I've had a struct like this: struct Attr { string value; } struct Foo { @(Attr("a attr")) enum a = Foo(10); @(Attr("b attr")) enum b = Foo(11); int x; int

How can I get this UDA at compile time?

2021-02-20 Thread Jack via Digitalmars-d-learn
I've had a struct like this: struct Attr { string value; } struct Foo { @(Attr("a attr")) enum a = Foo(10); @(Attr("b attr")) enum b = Foo(11); int x; int y; bool doY = true; int value() {

Re: How do I enable visual styles?

2021-02-18 Thread Jack via Digitalmars-d-learn
if someone happens to be looking to do that in the future: I didn't find a way to do this with a linker but managed to find a way to do this with code only. The code goes like this: // source: https://stackoverflow.com/a/10444161/800123 #include // NOTE: It is recommended that you delay-load

how to make this function nothrow?

2021-02-15 Thread Jack via Digitalmars-d-learn
I have to make my function nothrow because the function that calls it (not written by me) is nothrow. So I need to wrap my code in a try-catch() but how will I report the error message, if the toString() from Throwable isn't nothrow? how do I get out this circular dependence? void f()

Is there other way to do that?

2021-02-14 Thread Jack via Digitalmars-d-learn
I need to check if an instance is of a specific type derived from my base class but this class has template parameter and this type isn't available at time I'm checking it. Something like: class B { } class A(T) : B { } class X : B { } class Z : B { } auto c = can be any derived class from B

Is this the proper way to do it?

2021-02-12 Thread Jack via Digitalmars-d-learn
I have a base class A, where I make specific operator depending on the derived class type. Currently I'm using something like this: c is a class derived from A bool shouldDoX = (cast(X)c) !is null || (cast(Y)c) !is null || (cast(K)c) !is null ... ; as the number of cast(C) !is null is

Re: how to properly compare this type?

2021-02-12 Thread Jack via Digitalmars-d-learn
helpful always,thank you guys

  1   2   3   >