Re: serve-d and emacs

2021-05-01 Thread Imperatorn via Digitalmars-d-learn
On Friday, 30 April 2021 at 21:24:35 UTC, Christian Köstlin wrote: On 26.04.21 21:13, WebFreak001 wrote: On Monday, 26 April 2021 at 18:45:08 UTC, Christian Köstlin wrote: Does anybody use serve-d with emacs (lsp-mode or eglot)? I would love to see the configuration! Kind regards, Christian

Re: Should this always work?

2021-05-01 Thread frame via Digitalmars-d-learn
On Saturday, 1 May 2021 at 06:17:36 UTC, Mike Parker wrote: That only works when you're casting one class/interface reference to another. It doesn't > > work when you're casting raw pointers. Thanks for clarification. In case of a void* to abstract class casting, I assume the compiler ju

Re: nothrow and std.exception.ifThrown

2021-05-01 Thread novice2 via Digitalmars-d-learn
btw for my immediate needs i replace second delegate with value i.e. remove "lazy" from declaration and remove "()" in return so ifThrown loose some generity ```d nothrow CommonType!(T1, T2) ifThrown(E : Throwable = Exception, T1, T2) (lazy scope T1 expression, scope

Creating std.format.format warpper

2021-05-01 Thread novice2 via Digitalmars-d-learn
Hello. Can please anybody help me create template format2 like std.format.format, so it can access to format string (change it for example) then instantiate std.format.format template in compile-time-checkable way format!"%d %s"(arg1, arg2) so compiler can check format string vs arguments cou

Re: Should this always work?

2021-05-01 Thread Mike Parker via Digitalmars-d-learn
On Saturday, 1 May 2021 at 08:03:45 UTC, frame wrote: In case of a void* to abstract class casting, I assume the compiler just inserts the right vtable, so this cast is unproblematic - or is there also a pitfall? I wouldn't expect there to be any consideration of vtables whatsoever. The co

Re: dlang vs crystal-language

2021-05-01 Thread sighoya via Digitalmars-d-learn
On Wednesday, 28 April 2021 at 22:41:03 UTC, Alain De Vos wrote: What are the strengths and weaknesses comparing the two languages ? I can name a strength of dlang is the working binding to tk and gtk. Just to say, Crystal is a neat language, feels like a static ruby. Strengths: - Poweful ty

Re: betterC examples?

2021-05-01 Thread sfp via Digitalmars-d-learn
On Saturday, 1 May 2021 at 01:52:00 UTC, Mike Parker wrote: ... Mike, thanks for your detailed replies. They're both very helpful. What you described is what I figured I would need to do if I were to roll my own solution. I was hoping someone would have gone through the trouble of doing this

Re: Should this always work?

2021-05-01 Thread frame via Digitalmars-d-learn
On Saturday, 1 May 2021 at 10:08:17 UTC, Mike Parker wrote: So the pitfall is the same: when you're casting class references to and from pointers, it's up to you to ensure that the type you cast to is appropriate. You get no help from the compiler here. I see, this can be dangerous - yet, th

Re: Should this always work?

2021-05-01 Thread Mike Parker via Digitalmars-d-learn
On Saturday, 1 May 2021 at 15:21:28 UTC, frame wrote: btw: why is it even allowed to create an instance via cast as an abstract thing? No instance is being created by the cast. The instance already exists. The cast just allows you to treat the pointer to the instance as a specific type. It’

Re: Should this always work?

2021-05-01 Thread Steven Schveighoffer via Digitalmars-d-learn
On 5/1/21 12:55 AM, frame wrote: I always thought as long as an object implements an interface, it should be able to cast it from a void* if it really points to a supporting object. I have the similar structure: ```d interface AI {    string doSomething(); } template S() {    void foo() {

Re: Creating std.format.format warpper

2021-05-01 Thread Anonymouse via Digitalmars-d-learn
On Saturday, 1 May 2021 at 09:10:09 UTC, novice2 wrote: Hello. Can please anybody help me create template format2 like std.format.format, so it can access to format string (change it for example) then instantiate std.format.format template in compile-time-checkable way Since `std.format.for

Re: Since dmd 2.096.0: import `x.t` is used as a type

2021-05-01 Thread Basile B. via Digitalmars-d-learn
On Friday, 30 April 2021 at 21:41:43 UTC, kdevel wrote: On Friday, 30 April 2021 at 19:17:14 UTC, user1234 wrote: [...] Likely a side effect of https://github.com/dlang/dmd/pull/12178 but according to me the new behavior is correct. It breaks my code. I have files named $C containing struct o

Re: Should this always work?

2021-05-01 Thread frame via Digitalmars-d-learn
On Saturday, 1 May 2021 at 15:52:52 UTC, Mike Parker wrote: No instance is being created by the cast. The instance already exists. The cast just allows you to treat the pointer to the instance as a specific type. It’s no different than casting from C to A really. You just have the void* as an

Re: Creating std.format.format warpper

2021-05-01 Thread novice2 via Digitalmars-d-learn
On Saturday, 1 May 2021 at 16:21:33 UTC, Anonymouse wrote: https://run.dlang.io/is/QsYCkq http://ddili.org/ders/d.en/templates.html). thanks for your time!

Import static library by DUB (linking)

2021-05-01 Thread Wusiki via Digitalmars-d-learn
Lib: ``` module testlib; static string abc = "Hello World!"; ``` Source file: ``` module app; import std.stdio; import testlib; void main() { writeln(abc); } ``` Dub: ``` { "authors": [ "WJ" ], "copyright": "Copyright © 2020, ME", "descriptio

Re: dlang vs crystal-language

2021-05-01 Thread Vinod K Chandran via Digitalmars-d-learn
On Friday, 30 April 2021 at 14:49:33 UTC, Alain De Vos wrote: tkd works perfectly. Which O.S. are you using ? I can guide. I am using Windows 10 x64.

Re: dlang vs crystal-language

2021-05-01 Thread Vinod K Chandran via Digitalmars-d-learn
On Friday, 30 April 2021 at 17:01:52 UTC, TheGag96 wrote: I used tkD a long time ago. Look through [this repo](https://github.com/thegag96/codewrite) - maybe something in there will help you. Thanks for the link. Let me check.

Re: dlang vs crystal-language

2021-05-01 Thread Vinod K Chandran via Digitalmars-d-learn
On Friday, 30 April 2021 at 19:25:16 UTC, Siemargl wrote: I did this @2014. No problems remembered. May be it's my fault. Let me check once again.

Fake IFTI-compatible struct constructors

2021-05-01 Thread Chad Joan via Digitalmars-d-learn
I came up with a couple techniques for making it seem like templated structs deduce their template parameters from constructor invocations. These are given further down in the post. This has been a profitable exercise. However, the techniques I came up with have some drawbacks. Thus, I have

How do you compile DMD on Windows?

2021-05-01 Thread Blatnik via Digitalmars-d-learn
I wanna hack on the compiler, but I've spend 3 hours and I can't get the damned thing to compile! Building DMD itself was simple since there was a visual studio project (thank you to whoever made it), but for druntime and phobos I can't figure it out. The instructions on https://wiki.dlang.o

Re: How do you compile DMD on Windows?

2021-05-01 Thread MoonlightSentinel via Digitalmars-d-learn
On Saturday, 1 May 2021 at 22:44:34 UTC, Blatnik wrote: I wanna hack on the compiler, but I've spend 3 hours and I can't get the damned thing to compile! You probably need to update the VS paths to match your local installation, Microsoft apparently changed their directory layout a few years

Re: Fake IFTI-compatible struct constructors

2021-05-01 Thread Basile B. via Digitalmars-d-learn
On Saturday, 1 May 2021 at 21:57:54 UTC, Chad Joan wrote: I came up with a couple techniques for making it seem like templated structs deduce their template parameters from constructor invocations. These are given further down in the post. ... However, this was not to be. Rather, this setup d

Re: How do you compile DMD on Windows?

2021-05-01 Thread Blatnik via Digitalmars-d-learn
On Saturday, 1 May 2021 at 23:07:35 UTC, MoonlightSentinel wrote: You probably need to update the VS paths to match your local installation, Microsoft apparently changed their directory layout a few years ago AFAICT. Thanks for the tip. I think I managed to get it to work.. So not only did I

Re: How do you compile DMD on Windows?

2021-05-01 Thread Blatnik via Digitalmars-d-learn
On Saturday, 1 May 2021 at 23:49:49 UTC, Blatnik wrote: Here's hoping that phobos isn't as annoying >.> It is just as annoying. Even after patching the paths, still errors out.. ``` C:\D\phobos>make -f win64.mak -j4 phobos64.lib cd etc\c\zlib "make" -f win64.mak MODEL=64 zlib64.lib "CC=C:\Pr

Re: How do you compile DMD on Windows?

2021-05-01 Thread MoonlightSentinel via Digitalmars-d-learn
On Saturday, 1 May 2021 at 22:44:34 UTC, Blatnik wrote: They say to use the digitalmars make tool and not the normal make that I have installed. Great, no problem, except it didn't come installed with the compiler as is advertised. I don't have a make program in D/dmd2/windows/bin and I can't f

OutOfMemoryError in D DLL appending to module-level array

2021-05-01 Thread cc via Digitalmars-d-learn
Ordinarily, it seems legal to append to an array that has been declared at module level (or as a static class member) that hasn't been otherwise initialized, for example: ```d class Foo {} private Foo[] cache; void main() { auto foo = new Foo(); cache ~= foo; } ``` However, when

Re: OutOfMemoryError in D DLL appending to module-level array

2021-05-01 Thread cc via Digitalmars-d-learn
On Sunday, 2 May 2021 at 02:34:41 UTC, cc wrote: [...] Just to add, only appending to the array seems to give OutOfMemoryErrors. I can idup strings, call stdc malloc, etc just fine.

Re: OutOfMemoryError in D DLL appending to module-level array

2021-05-01 Thread Adam D. Ruppe via Digitalmars-d-learn
On Sunday, 2 May 2021 at 02:34:41 UTC, cc wrote: which seems to fix it, but I'm not entirely sure what's going on, if this is expected behavior, if that's the correct way to handle it, and so on. Oh I've been working on this the last couple weeks and having a hard time reproducing outside the

Re: Import static library by DUB (linking)

2021-05-01 Thread Mike Parker via Digitalmars-d-learn
On Saturday, 1 May 2021 at 18:30:26 UTC, Wusiki wrote: Lib: ``` module testlib; static string abc = "Hello World!"; ``` FYI, `static` has no meaning at module scope. ``` (Can't find -ltestlib) What am I do wrong? How can I link my library with my app? Did you compile `testlib.d` into a l

Re: Fake IFTI-compatible struct constructors

2021-05-01 Thread Chad Joan via Digitalmars-d-learn
On Saturday, 1 May 2021 at 23:21:33 UTC, Basile B. wrote: On Saturday, 1 May 2021 at 21:57:54 UTC, Chad Joan wrote: ... Rather, this setup doesn't work at all, because IFTI doesn't seem to work on function-templates with alias parameters. Yes your observation is correct. That should work but

Re: OutOfMemoryError in D DLL appending to module-level array

2021-05-01 Thread cc via Digitalmars-d-learn
On Sunday, 2 May 2021 at 02:42:46 UTC, Adam D. Ruppe wrote: On Sunday, 2 May 2021 at 02:34:41 UTC, cc wrote: which seems to fix it, but I'm not entirely sure what's going on, if this is expected behavior, if that's the correct way to handle it, and so on. Oh I've been working on this the last

Re: Import static library by DUB (linking)

2021-05-01 Thread Wusiki via Digitalmars-d-learn
On Sunday, 2 May 2021 at 04:42:42 UTC, Mike Parker wrote: On Saturday, 1 May 2021 at 18:30:26 UTC, Wusiki wrote: FYI, `static` has no meaning at module scope. Ok, I replaced abc to abc() string function; Did you compile `testlib.d` into a library? I only ask because you didn't show a comman