Re: Is @live attribute working yet?

2022-04-24 Thread Tejas via Digitalmars-d-learn
On Sunday, 24 April 2022 at 09:31:40 UTC, elfstone wrote: Dub(DMD 2.099.1) builds and runs the following code without a warning. import std.stdio; import core.stdc.stdlib; @live void test() { int* p = cast(int*) malloc(32); p = cast(int*) malloc(32);

Re: Back to Basics at DConf?

2022-05-12 Thread Tejas via Digitalmars-d-learn
On Friday, 13 May 2022 at 03:31:53 UTC, Ali Çehreli wrote: On 5/12/22 18:56, forkit wrote: > So...you want to do a talk that challenges D's complexity, by getting > back to basics? I wasn't thinking about challenging complexity but it gives me ideas. I am looking for concrete topics like

Re: Back to Basics at DConf?

2022-05-12 Thread Tejas via Digitalmars-d-learn
On Friday, 13 May 2022 at 04:19:26 UTC, Ola Fosheim Grøstad wrote: On Friday, 13 May 2022 at 03:31:53 UTC, Ali Çehreli wrote: On 5/12/22 18:56, forkit wrote: > So...you want to do a talk that challenges D's complexity, by getting > back to basics? I wasn't thinking about challenging

Re: D WebAssembly working differently than C++, Zig

2022-05-17 Thread Tejas via Digitalmars-d-learn
On Tuesday, 17 May 2022 at 09:38:31 UTC, Sergey wrote: On Monday, 16 May 2022 at 17:32:20 UTC, Allen Garvey wrote: I'm working on a comparison of WebAssembly performance for error propagation dithering using D, C++ and Zig. So far C++ and Zig work as expected, but for D, despite using the same

Re: Why are structs and classes so different?

2022-05-15 Thread Tejas via Digitalmars-d-learn
On Sunday, 15 May 2022 at 21:33:24 UTC, Ali Çehreli wrote: D programmers don't write move constructors or move assignment. Such concepts don't even exist. Never say never : https://github.com/dlang/DIPs/blob/master/DIPs/DIP1040.md Walter is one of the authors of the DIP Also, there's

Re: Language server

2022-05-17 Thread Tejas via Digitalmars-d-learn
On Wednesday, 18 May 2022 at 01:04:16 UTC, Alain De Vos wrote: I tried neovim editor & serve-d and failed. I tried kate editor & serve-d and failed. https://github.com/Pure-D/serve-d Anyone has a clue ? I'm using [lunarvim](https://github.com/LunarVim/LunarVim). It provides you the ability

Re: Unexplainable behaviour with direct struct assignment.

2022-05-18 Thread Tejas via Digitalmars-d-learn
On Wednesday, 18 May 2022 at 21:52:18 UTC, HuskyNator wrote: On Wednesday, 18 May 2022 at 21:49:14 UTC, HuskyNator wrote: After updating to `DMD 2.100.0` & `DUB 1.29.0`, I still get this behavior. Only when I use `dub run --b=debug` however (default for me). `dub run --b=release` does return

Re: Inferred attributes errors in template function.

2022-05-27 Thread Tejas via Digitalmars-d-learn
On Friday, 27 May 2022 at 08:39:08 UTC, vit wrote: Hello, I have this problem: ```d static int i; void bar(T)(){ static if(is(T == int)) (()@system => 1)(); static if(is(T == float)) i = 42; } void foo(T)(){ bar!T(); } void main()@safe pure{

Re: static assert("nothing")

2022-05-31 Thread Tejas via Digitalmars-d-learn
On Tuesday, 31 May 2022 at 08:51:45 UTC, realhet wrote: Hi, In my framework I just found a dozen of compile time error handling like: ...else static assert("Invalid type"); This compiles without error. And it was useless for detecting errors because I forgot the first "false" or "0"

Re: Anybody have any idea on how to do shared operator overloads?

2022-06-01 Thread Tejas via Digitalmars-d-learn
On Thursday, 2 June 2022 at 01:49:32 UTC, Ruby The Roobster wrote: On Thursday, 2 June 2022 at 01:29:39 UTC, Ruby The Roobster wrote: On Thursday, 2 June 2022 at 01:00:57 UTC, Ali Çehreli wrote: On 6/1/22 17:36, Ruby The Roobster wrote: > A stripped down version of some code I have: Not much

Re: What are (were) the most difficult parts of D?

2022-05-12 Thread Tejas via Digitalmars-d-learn
On Thursday, 12 May 2022 at 15:18:34 UTC, jmh530 wrote: On Thursday, 12 May 2022 at 12:13:32 UTC, Basile B. wrote: [snip] ``` is ( Type : TypeSpecialization , TemplateParameterList ) is ( Type == TypeSpecialization , TemplateParameterList ) is ( Type Identifier : TypeSpecialization ,

Re: How to call destroy() in @nogc?

2022-05-23 Thread Tejas via Digitalmars-d-learn
On Tuesday, 24 May 2022 at 02:29:38 UTC, cc wrote: ```d import core.memory; import core.stdc.stdlib : malloc, free; import core.lifetime : emplace; [...] FWIW your code will compile if you add `extern(C++)` to `Foo`

Re: gdc 12.1: undefined references when linking separately compiled files

2022-05-28 Thread Tejas via Digitalmars-d-learn
On Saturday, 28 May 2022 at 13:12:46 UTC, kdevel wrote: I am trying to build a project with GDC. It successfully compiles with dmd and ldmd2. When I use gdc in one go the binary is successfully build: [...] Is seperate compilation working successfully for dmd and ldc? The only bug I know

Re: UI Library

2022-05-20 Thread Tejas via Digitalmars-d-learn
On Friday, 20 May 2022 at 02:37:48 UTC, harakim wrote: I need to write a piece of software to track and categorize some purchases. It's the kind of thing I could probably write in a couple of hours in C#/Java + html/css/javascript. However, something keeps drawing me to D and as this is a

Re: Better way to achieve the following

2022-06-21 Thread Tejas via Digitalmars-d-learn
On Tuesday, 21 June 2022 at 17:09:28 UTC, JG wrote: Suppose we are often writing something like ```d theFirstName[theFirstIndex].theSecondName[theSecondIndex].thirdName[theThirdIndex]=x; ``` One would like to something like ```d alias shortName =

Re: Python <==> d call both ways example (with PyD and autowrap)?

2022-06-22 Thread Tejas via Digitalmars-d-learn
On Wednesday, 22 June 2022 at 16:02:00 UTC, mw wrote: Hi, I know with PyD, D can call Python, and with autowrap, Python can call a D .dll, I'm just wondering if someone can show an example that Python <==> d can call both ways? esp. show passing D objects to Python and then call its member

Re: UFCS limit

2022-06-16 Thread Tejas via Digitalmars-d-learn
On Friday, 17 June 2022 at 01:04:28 UTC, Paul Backus wrote: Nope. The way UFCS works is that allows you to call free functions using member-function syntax, and member-function syntax is always `object.memberName`, so UFCS only works for functions that have a name, not anonymous functions.

Re: Can I create a package with friendly modules

2022-06-13 Thread Tejas via Digitalmars-d-learn
On Sunday, 12 June 2022 at 05:05:46 UTC, forkit wrote: Is it possible to create a package.d, consisting of (for example), two modules, where each module can access private declarations within each other. In essence, declaring 'a module level friendship', or a kind of 'extended module' if you

Re: Error: cannot use non-constant CTFE pointer in an initializer `cast(immutable(char)*)TEST`

2022-06-11 Thread Tejas via Digitalmars-d-learn
On Saturday, 11 June 2022 at 11:51:43 UTC, Tejas wrote: On Saturday, 11 June 2022 at 10:07:46 UTC, test123 wrote: how to work this around. ```d __gshared const TEST = import(`onlineapp.d`); extern(C) void main(){ __gshared bin_ptr = TEST.ptr; } ``` ```sh dmd2 -betterC -J. onlineapp.d

Re: Error: cannot use non-constant CTFE pointer in an initializer `cast(immutable(char)*)TEST`

2022-06-11 Thread Tejas via Digitalmars-d-learn
On Saturday, 11 June 2022 at 10:07:46 UTC, test123 wrote: how to work this around. ```d __gshared const TEST = import(`onlineapp.d`); extern(C) void main(){ __gshared bin_ptr = TEST.ptr; } ``` ```sh dmd2 -betterC -J. onlineapp.d onlineapp.d(3): Error: cannot use non-constant CTFE

Re: T... args!

2022-04-29 Thread Tejas via Digitalmars-d-learn
On Friday, 29 April 2022 at 16:10:52 UTC, Salih Dincer wrote: On Friday, 29 April 2022 at 12:57:15 UTC, Steven Schveighoffer wrote: [...] I see, think it can be done with mixin: ```d template prn(alias args) { string prn() { string result = "write("; foreach(s; args.split("|"))

Re: How to use destroy and free.

2022-04-30 Thread Tejas via Digitalmars-d-learn
On Saturday, 30 April 2022 at 09:25:18 UTC, Dukc wrote: On Sunday, 24 April 2022 at 21:00:50 UTC, Alain De Vod wrote: [...] A few picks. 1: You do not need to import `destroy`. Everything in `object` is automatically imported. [...] Hell, just using `scope int[] i` should be enough to

Re: error connecting to mongodb atlas with vibe.d

2022-05-01 Thread Tejas via Digitalmars-d-learn
On Saturday, 30 April 2022 at 14:29:56 UTC, notsteve wrote: Hi, I am trying to setup a simple webserver in D using vibe.d (0.9.4) and want to use mongoDB as a database. To achieve this, I've set up a mongoDB atlas instance with the following command inside the standard app.d file created by

Re: Parameters declared as the alias of a template won't accept the arguments of the same type.

2022-05-01 Thread Tejas via Digitalmars-d-learn
On Sunday, 1 May 2022 at 03:57:12 UTC, Elfstone wrote: module test; struct MatrixImpl(S, size_t M, size_t N) { } [...] AFAICT, I'm afraid you'll have to stick to `dot2`  This DIP I believe does what you want but... It wasn't looked upon favorably...

Re: Google Code Jam 2022

2022-05-06 Thread Tejas via Digitalmars-d-learn
On Friday, 6 May 2022 at 08:25:34 UTC, Siarhei Siamashka wrote: On Friday, 6 May 2022 at 07:05:35 UTC, zjh wrote: For example, I think `d` can also make use of `'winrt'`, which is very important for `GUI` programming . `D` officials should pay attention to `it`. I have downloaded `dwinrt`

Re: Compile delegate with enum into proper function?

2022-05-07 Thread Tejas via Digitalmars-d-learn
On Sunday, 8 May 2022 at 01:38:55 UTC, jmh530 wrote: On Saturday, 7 May 2022 at 23:30:37 UTC, Paul Backus wrote: [snip] Worth noting that you *can* write ```d alias foo = partial!(foo, a); ``` ...which will add the partially-applied version to `foo`'s overload set. You sure about that?

Re: Compile delegate with enum into proper function?

2022-05-08 Thread Tejas via Digitalmars-d-learn
On Saturday, 7 May 2022 at 18:36:40 UTC, jmh530 wrote: In the code below, there is a two parameter function `foo` and an override of it with only one parameter. In the override case, I force the second one to be 1, but ideally there should be a way to specify it at compile-time. It would be

Re: T... args!

2022-04-29 Thread Tejas via Digitalmars-d-learn
On Friday, 29 April 2022 at 12:57:15 UTC, Steven Schveighoffer wrote: On 4/28/22 10:48 PM, Salih Dincer wrote: [...] There is no string interpolation in D. You can use a function such as `std.conv.text` to produce a string given interleaving strings and items. Or you can use

Re: Parameters declared as the alias of a template won't accept the arguments of the same type.

2022-05-02 Thread Tejas via Digitalmars-d-learn
On Monday, 2 May 2022 at 22:01:51 UTC, ag0aep6g wrote: On 02.05.22 22:47, Stanislav Blinov wrote: On Monday, 2 May 2022 at 20:16:04 UTC, ag0aep6g wrote: On 02.05.22 21:17, Stanislav Blinov wrote: On Monday, 2 May 2022 at 16:29:05 UTC, Loara wrote: [...] ```d     template MyAlias(T){  

Re: Parameters declared as the alias of a template won't accept the arguments of the same type.

2022-05-02 Thread Tejas via Digitalmars-d-learn
On Tuesday, 3 May 2022 at 00:38:34 UTC, Tejas wrote: On Monday, 2 May 2022 at 22:01:51 UTC, ag0aep6g wrote: On 02.05.22 22:47, Stanislav Blinov wrote: On Monday, 2 May 2022 at 20:16:04 UTC, ag0aep6g wrote: On 02.05.22 21:17, Stanislav Blinov wrote: On Monday, 2 May 2022 at 16:29:05 UTC,

Re: How to use destroy and free.

2022-05-03 Thread Tejas via Digitalmars-d-learn
On Tuesday, 3 May 2022 at 12:59:31 UTC, Alain De Vos wrote: Error: array literal in @nogc function test.myfun may cause a GC allocation @nogc void myfun(){ scope int[] i=[1,2,3]; }//myfun May is a fuzzy word... For this particular piece of code, you can use a static array to

Re: Parameters of overloaded templated function

2022-05-10 Thread Tejas via Digitalmars-d-learn
On Tuesday, 10 May 2022 at 11:33:24 UTC, frame wrote: On Tuesday, 10 May 2022 at 11:26:44 UTC, frame wrote: On Tuesday, 10 May 2022 at 03:18:14 UTC, Tejas wrote: Can you try Makes no difference. OK, I tried it in separate test and works. Weird, I already tried that before, there must be

Re: What are (were) the most difficult parts of D?

2022-05-11 Thread Tejas via Digitalmars-d-learn
On Wednesday, 11 May 2022 at 14:20:07 UTC, H. S. Teoh wrote: On Wed, May 11, 2022 at 01:37:21PM +, matheus via Digitalmars-d-learn wrote: > [...] [...] [...] [...] My suggestion is: when prototyping, don't even think about attributes. Just templatize your functions and let the compiler

Re: Parameters of overloaded templated function

2022-05-09 Thread Tejas via Digitalmars-d-learn
On Tuesday, 10 May 2022 at 01:00:24 UTC, frame wrote: So `__traits(getOverloads)` returns also templated members and `__traits(isTemplate)` can select those members. Unfortunately, `Parameters!` does not work with the templated member. How can I pass a symbol of T or A... to `Parameters!` as

Re: Constructors not working

2022-09-02 Thread Tejas via Digitalmars-d-learn
On Friday, 2 September 2022 at 18:39:27 UTC, rikki cattermole wrote: I think you are wanting opAssign not opBinary. Also you made a mistake, since its a struct you don't want to new it when you construct and return it. ```d return new Time(secos / 3600, (secos % 3600) / 60, secos % 60); ```

Re: "Error: no property `offsetof` for type `char*`"

2022-08-19 Thread Tejas via Digitalmars-d-learn
On Friday, 19 August 2022 at 16:36:24 UTC, MyNameHere wrote: On Friday, 19 August 2022 at 14:30:50 UTC, kinke wrote: Oh and `DevicePath()` is a convenience member returning a pointer to the 'dynamic array' (as the array decays to a pointer in C too), so no need to fiddle with `.offsetof` and

Re: Find in assoc array then iterate

2022-10-22 Thread Tejas via Digitalmars-d-learn
On Friday, 21 October 2022 at 22:03:53 UTC, Kevin Bailey wrote: I'm trying to do this equivalent C++: unordered_map map; for (auto i = map.find(something); i != map.end(); ++i) ...do something with i... in D, but obviously with an associative array. It seems that it's quite

Re: Can you access the same classes from C++ and D and vise versa, or do the classes have to not form dependency cycle?

2022-09-14 Thread Tejas via Digitalmars-d-learn
On Tuesday, 13 September 2022 at 03:13:59 UTC, Daniel Donnell, Jr wrote: On Sunday, 11 September 2022 at 02:14:51 UTC, zjh wrote: On Saturday, 10 September 2022 at 22:07:32 UTC, Ali Çehreli wrote: On 9/10/22 13:04, Daniel Donnell wrote: > https://dlang.org/spec/cpp_interface.html At DConf,

Re: Detect uninitialized class var access

2022-09-24 Thread Tejas via Digitalmars-d-learn
On Saturday, 24 September 2022 at 23:04:00 UTC, rassoc wrote: On 9/24/22 15:28, Adam D Ruppe via Digitalmars-d-learn wrote: gdb --args ./your_program and then it will tell you all the details you want to know about when this happens. Thank you for your input, Adam. Real shame that there's

Re: Arbitrary precision decimal numbers

2022-08-10 Thread Tejas via Digitalmars-d-learn
On Wednesday, 10 August 2022 at 14:11:04 UTC, Ruby The Roobster wrote: On Saturday, 6 August 2022 at 13:20:19 UTC, Sergey wrote: On Thursday, 4 August 2022 at 13:01:30 UTC, Ruby The Roobster wrote: Is there any implementation in phobos of something similar to BigInt but for non-integers as

Re: A strange DMD error

2022-11-01 Thread Tejas via Digitalmars-d-learn
On Tuesday, 1 November 2022 at 15:49:54 UTC, Keivan Shah wrote: On Tuesday, 1 November 2022 at 15:42:43 UTC, Imperatorn wrote: On Tuesday, 1 November 2022 at 15:40:04 UTC, Keivan Shah wrote: Hello, Today I came across a strange bug while using D with `dmd`. I have still not been able to

Re: Make IN Dlang

2022-11-01 Thread Tejas via Digitalmars-d-learn
On Tuesday, 1 November 2022 at 23:40:22 UTC, Christian Köstlin wrote: Dear dlang-folk, one of the tools I always return to is rake (https://ruby.github.io/rake/). For those that do not know it, its a little like make in the sense that you describe your build as a graph of tasks with

Re: Can you simplify nested Indexed types?

2022-12-27 Thread Tejas via Digitalmars-d-learn
On Tuesday, 27 December 2022 at 15:09:11 UTC, Sergei Nosov wrote: Consider, I have the following code: ``` auto a = [3, 6, 2, 1, 5, 4, 0]; auto indicies = iota(3); auto ai = indexed(a, indicies); ai = indexed(ai, iota(2)); writeln(ai); ``` Basically, my idea is to apply

Re: How to avoid variable capturing in `foreach` loop with lambdas?

2023-01-05 Thread Tejas via Digitalmars-d-learn
On Thursday, 5 January 2023 at 22:49:01 UTC, thebluepandabear wrote: Have fun reading this : https://issues.dlang.org/show_bug.cgi?id=21929 Thanks for the code suggestion although it still doesn't fix the bug. I am curious as to what those brackets do as well. Okay, my bad for writing the

Re: How to avoid variable capturing in `foreach` loop with lambdas?

2023-01-05 Thread Tejas via Digitalmars-d-learn
On Thursday, 5 January 2023 at 11:55:33 UTC, thebluepandabear wrote: I am using CSFML D bindings and I have created my own sort of UI library for drawing elements onto the screen. One of the classes I've created is a `Button` class, which contains a delegate called `onButtonClick` which is

Re: forgetting -betterC means no runtime bounds checking?

2023-01-05 Thread Tejas via Digitalmars-d-learn
On Thursday, 5 January 2023 at 09:10:00 UTC, areYouSureAboutThat wrote: I was playing around with betterC, when I discovered, that if i accidently forget to provide -betterC to the compiler, it will still compile this, but, there will be no runtime bounds checking occuring. My question is:

Re: Is defining get/set methods for every field overkill?

2022-11-23 Thread Tejas via Digitalmars-d-learn
On Wednesday, 23 November 2022 at 11:06:12 UTC, []() {}() wrote: On Wednesday, 23 November 2022 at 09:51:46 UTC, FeepingCreature wrote: Why then should a programming language insist that all other code in the module should be able to bypass my specification, and do as it pleases to my

Re: pointer escaping return scope bug?

2022-11-25 Thread Tejas via Digitalmars-d-learn
On Friday, 25 November 2022 at 17:45:57 UTC, Paul Backus wrote: On Friday, 25 November 2022 at 14:07:28 UTC, ShadoLight wrote: On Saturday, 19 November 2022 at 15:00:16 UTC, Paul Backus wrote: Since, in your example, `lf` has global lifetime, the compiler deduces that `lf.fp` also has global

Re: How to move from Unique(someClass) to Unique(someInterface)?

2022-11-27 Thread Tejas via Digitalmars-d-learn
On Sunday, 27 November 2022 at 17:06:31 UTC, vushu wrote: On Saturday, 16 May 2020 at 17:45:56 UTC, Konstantin wrote: [...] I'm actually also very curious about this issue, since I come from c++ where this is possible, and it is a very common functionality for example for dependency

Re: What's the correct way of creating an instance of class in D?

2022-11-03 Thread Tejas via Digitalmars-d-learn
On Thursday, 3 November 2022 at 04:41:14 UTC, Siarhei Siamashka wrote: C++ code: ```C++ #include class A { public: void foo() { std::cout << "foo" << std::endl; } }; int main() { auto a1 = new A; a1->foo(); // prints "foo" A a2; a2.foo(); // prints "foo" delete a1; } ``` D code:

Re: dmd as a library

2022-11-07 Thread Tejas via Digitalmars-d-learn
On Tuesday, 8 November 2022 at 00:05:18 UTC, vushu wrote: Any where to find learning material for using dmd as a library? thanks. https://github.com/Superbelko/dmdlib-notes This is the only resource I know of

Re: What's the correct way of creating an instance of class in D?

2022-11-03 Thread Tejas via Digitalmars-d-learn
On Thursday, 3 November 2022 at 15:40:02 UTC, H. S. Teoh wrote: On Thu, Nov 03, 2022 at 04:41:14AM +, Siarhei Siamashka via Digitalmars-d-learn wrote: [...] ```D @safe: import std.stdio; class A { void foo() { writeln("foo"); } } void main() { auto a1 = new A; a1.foo(); // prints

Re: Sorted Array (Container) Type

2022-11-13 Thread Tejas via Digitalmars-d-learn
On Sunday, 13 November 2022 at 18:51:09 UTC, Siarhei Siamashka wrote: On Saturday, 12 November 2022 at 14:07:46 UTC, Per Nordlöw wrote: Have anybody created a wrapper container ```d struct Sorted(ArrayLike, alias lessThanPred) ``` that wraps an array-like type `ArrayLike` so that it's always

<    1   2   3