Should 'in' Imply 'ref' as Well for Value Types?

2018-05-04 Thread Vijay Nayar via Digitalmars-d
While working on a library built for high efficiency, avoiding unnecessary copies of structs became an issue. I had assumed that `in` was doing this, but a bit of experimentation revealed that it does not. However, `ref in` works great. My question is, should `in` by default also imply

Bug?: Presence of "init()" Method Causes std.array.appender to Fail to Compile

2018-05-13 Thread Vijay Nayar via Digitalmars-d
I encountered a very unexpected error when working on a project. It seems that the Appender and RefAppender structs created from the std.array.appender() method are sensitive to the mere presence of a method called "init()" on the element type of the array. Here is a minimal example: ```

Clash When Using Function as Template Value-Parameters?

2018-05-26 Thread Vijay Nayar via Digitalmars-d
I've been experimenting with code that uses std.functional : binaryFun and unaryFun, but I have found that using these methods makes it impossible to add function attributes like @safe, @nogc, pure, and nothrow, because no guarantee can be made about the functions created via a stream. For

Re: What's happening with the `in` storage class

2018-06-12 Thread Vijay Nayar via Digitalmars-d
On Saturday, 9 June 2018 at 02:38:14 UTC, SonicFreak94 wrote: On Saturday, 9 June 2018 at 02:17:18 UTC, Adam D. Ruppe wrote: On Saturday, 9 June 2018 at 02:13:00 UTC, Walter Bright wrote: But it was never enforced, meaning that suddenly enforcing it is just going to break code left and right.

Re: Clash When Using Function as Template Value-Parameters?

2018-05-29 Thread Vijay Nayar via Digitalmars-d
On Tuesday, 29 May 2018 at 12:58:20 UTC, Yuxuan Shui wrote: I believe that is the case. Normally that will be fine, because you can't modify them. Type-deduced lambda is a very special case, as in their parameter types are deduced on first use, so in a sense, they are "modified" by the first

Re: General problem I'm having in D with the type system

2018-05-27 Thread Vijay Nayar via Digitalmars-d
On Sunday, 27 May 2018 at 06:00:30 UTC, IntegratedDimensions wrote: The problem description is not very clear, but the catfood example gives a bit more to work with. animal -> food || vv cat -> catfood Of course, I'm not sure how to avoid the problem

Re: Friends in D, a new idiom?

2018-05-27 Thread Vijay Nayar via Digitalmars-d
On Sunday, 27 May 2018 at 06:37:56 UTC, IntegratedDimensions wrote: I'm looking for something lightweight and direct. It is not for total encapsulation control but to simply provide an extra level of indirection for write access to make the object look read only to those that directly use

Re: Clash When Using Function as Template Value-Parameters?

2018-05-27 Thread Vijay Nayar via Digitalmars-d
On Saturday, 26 May 2018 at 11:56:30 UTC, Vijay Nayar wrote: The error is: ``` onlineapp.d(8): Error: function literal `__lambda6(char a)` is not callable using argument types `(int)` onlineapp.d(8):cannot pass argument `val` of type `int` to parameter `char a` onlineapp.d(15): Error:

Re: Friends in D, a new idiom?

2018-05-27 Thread Vijay Nayar via Digitalmars-d
On Sunday, 27 May 2018 at 05:25:53 UTC, IntegratedDimensions wrote: Re: Friends in D, a new idiom? In D, there's no exact equivalent to friend, but there are a few more specialized tools at your disposal. Normally all code in the same module is essentially a friend, so if the classes you

Re: Clash When Using Function as Template Value-Parameters?

2018-05-30 Thread Vijay Nayar via Digitalmars-d
On Tuesday, 29 May 2018 at 19:17:37 UTC, Vijay Nayar wrote: On Tuesday, 29 May 2018 at 12:58:20 UTC, Yuxuan Shui wrote: [...] I tried this again, this time completely ignoring lambdas and completely specifying the desired type like so: [...] Issue created:

Re: Clash When Using Function as Template Value-Parameters?

2018-05-29 Thread Vijay Nayar via Digitalmars-d
On Tuesday, 29 May 2018 at 11:36:11 UTC, Yuxuan Shui wrote: No, wait a second. (a)=>a is in default argument list, so it is in the global scope. And it was instantiated when you instantiate BTree with char. Could you explain that part a bit for me? Yes, (a) => a is a default value, but

Re: Clash When Using Function as Template Value-Parameters?

2018-05-28 Thread Vijay Nayar via Digitalmars-d
On Sunday, 27 May 2018 at 20:38:25 UTC, Daniel Kozak wrote: I would rewrite it to something like this: template BTree(ValueT, KeyT = ValueT,alias KeyF = unaryFun!"cast(const)a") { class BTree { This is roughly what I originally had, but it creates a number of problems that I wanted

Re: Expanding tool (written in D) use, want advice

2018-06-25 Thread Vijay Nayar via Digitalmars-d
On Friday, 22 June 2018 at 14:45:46 UTC, Jesse Phillips wrote: Should I be looking more at the benefits of having D as a tool? It was a good choice for me since I know D so well (and other reasons at the time), but C# is a reasonable language in this space. I'm thinking, like should I go into

Associative Array that Supports upper/lower Ranges

2018-06-25 Thread Vijay Nayar via Digitalmars-d
I was in need of an associative array / dictionary object that could also support getting ranges of entries with keys below or above a given value. I couldn't find anything that would do this, and ended up using the RedBlackTree to store key/value pairs, and then wrap the relevant functions

Re: A Friendly Challenge for D

2018-10-13 Thread Vijay Nayar via Digitalmars-d
On Friday, 12 October 2018 at 21:08:03 UTC, Jabari Zakiya wrote: On Friday, 12 October 2018 at 20:05:29 UTC, welkam wrote: On Friday, 12 October 2018 at 16:19:59 UTC, Jabari Zakiya wrote: The real point of the challenge is too see what idiomatic code... There is no idiomatic D code. There is

Re: A Friendly Challenge for D

2018-10-14 Thread Vijay Nayar via Digitalmars-d
On Saturday, 13 October 2018 at 19:04:48 UTC, Jabari Zakiya wrote: On Saturday, 13 October 2018 at 18:31:57 UTC, Vijay Nayar wrote: On Saturday, 13 October 2018 at 18:14:20 UTC, Vijay Nayar wrote: On Saturday, 13 October 2018 at 18:05:45 UTC, Jabari Zakiya wrote: It may be also running into

Re: A Friendly Challenge for D

2018-10-15 Thread Vijay Nayar via Digitalmars-d
On Sunday, 14 October 2018 at 10:51:11 UTC, Vijay Nayar wrote: Once I get the bugs out, I'm curious to see if any performance differences crop up. There's the theory that says they should be the same, and then there's the practice. I don't actually understand the underlying algorithm, but I

Re: A Friendly Challenge for D

2018-10-16 Thread Vijay Nayar via Digitalmars-d
On Monday, 15 October 2018 at 22:17:57 UTC, Jabari Zakiya wrote: $ dub build --compiler=ldc2 -b=release && echo "30" | ./twinprimes Enter integer number: threads = 8 each thread segment is [1 x 65536] bytes array twinprime candidates = 175324676; resgroups = 1298702 each 135 threads has

Re: Shared - Another Thread

2018-10-18 Thread Vijay Nayar via Digitalmars-d
On Wednesday, 17 October 2018 at 21:12:49 UTC, Stefan Koch wrote: Hi, reading the other shared thread "shared - i need to be useful"(https://forum.dlang.org/thread/mailman.4299.1539629222.29801.digitalmar...@puremagic.com) let me to an important realisation concerning the reason shareding

Re: Interesting Observation from JAXLondon

2018-10-12 Thread Vijay Nayar via Digitalmars-d
On Friday, 12 October 2018 at 07:13:33 UTC, Russel Winder wrote: On Thu, 2018-10-11 at 13:00 +, bachmeier via Digitalmars-d wrote: […] Suggestions? My guess is that the reason they've heard of those languages is because their developers were writing small projects using Go and Rust, but

Re: A Friendly Challenge for D

2018-10-13 Thread Vijay Nayar via Digitalmars-d
On Saturday, 13 October 2018 at 14:32:33 UTC, welkam wrote: On Saturday, 13 October 2018 at 09:22:16 UTC, Vijay Nayar wrote: I downloaded the reference NIM implementation and got the latest nim compiler, but I received the following error: $ nim c --cc:gcc --d:release --threads:on

Re: A Friendly Challenge for D

2018-10-13 Thread Vijay Nayar via Digitalmars-d
On Saturday, 13 October 2018 at 15:19:07 UTC, Jabari Zakiya wrote: On Saturday, 13 October 2018 at 14:32:33 UTC, welkam wrote: On Saturday, 13 October 2018 at 09:22:16 UTC, Vijay Nayar wrote: [...] import algorithm thats all but then it spits out lib/nim/pure/algorithm.nim(144, 11) Error:

Re: A Friendly Challenge for D

2018-10-13 Thread Vijay Nayar via Digitalmars-d
On Saturday, 13 October 2018 at 18:05:45 UTC, Jabari Zakiya wrote: It may be also running into a hard time limit imposed on compilation that Nim had/has that prevented my code from initially compiling. I'm generating a lot of PG parameter constants at compile time, and it's doing a lot of

Re: A Friendly Challenge for D

2018-10-13 Thread Vijay Nayar via Digitalmars-d
On Saturday, 13 October 2018 at 15:50:06 UTC, Vijay Nayar wrote: On Saturday, 13 October 2018 at 15:19:07 UTC, Jabari Zakiya wrote: On Saturday, 13 October 2018 at 14:32:33 UTC, welkam wrote: On Saturday, 13 October 2018 at 09:22:16 UTC, Vijay Nayar wrote: [...] import algorithm thats all

Re: A Friendly Challenge for D

2018-10-13 Thread Vijay Nayar via Digitalmars-d
On Saturday, 13 October 2018 at 18:14:20 UTC, Vijay Nayar wrote: On Saturday, 13 October 2018 at 18:05:45 UTC, Jabari Zakiya wrote: It may be also running into a hard time limit imposed on compilation that Nim had/has that prevented my code from initially compiling. I'm generating a lot of

Re: Interesting Observation from JAXLondon

2018-10-11 Thread Vijay Nayar via Digitalmars-d
On Thursday, 11 October 2018 at 11:50:39 UTC, Joakim wrote: On Thursday, 11 October 2018 at 07:58:39 UTC, Russel Winder wrote: This was supposed to come to this list not the learn list. On Thu, 2018-10-11 at 07:57 +0100, Russel Winder wrote: It seems that in the modern world of Cloud and

range.put() to Empty Array Causes Error?

2018-06-17 Thread Vijay Nayar via Digitalmars-d-learn
This code breaks with the following error: void main() { import std.range; int[] vals = []; vals.put(3); } /src/phobos/std/range/primitives.d(2328): Attempting to fetch the front of an empty array of int The following code has no error: void main() { import

detectcycles: A source code dependency cycle checker

2018-06-17 Thread Vijay Nayar via Digitalmars-d-announce
https://github.com/vnayar/detectcycles I made a small configurable tool to detect software source dependency cycles that is configurable to use for most languages. By default, C++, Java, and D are supported, but add new languages is as simple as adding a few lines to JSON configuation file.

Re: detectcycles: A source code dependency cycle checker

2018-06-18 Thread Vijay Nayar via Digitalmars-d-announce
On Sunday, 17 June 2018 at 20:20:48 UTC, Mario Kröplin wrote: I did not mention it in the README, but the tred filter used in https://code.dlang.org/packages/depend complains about cyclic dependencies. I am currently working on a branch, where the transitive reduction and the corresponding

Preferred Alias Declaration Style

2018-06-27 Thread Vijay Nayar via Digitalmars-d-learn
Most of the documentation at https://dlang.org/spec/declaration.html#alias uses examples of the form: `alias aliasName = other;`, where `aliasName` becomes the new name to reference `other`. Alternatively, one may write `alias other aliasName;`. My understanding is that the syntax with `=`

Implicit Template Parameters Cannot Decipher Aliases?

2018-04-25 Thread Vijay Nayar via Digitalmars-d-learn
I have encountered a problem where whenever I attempt to use a templated function with alias that partially limits the type of the arguments, the program fails to compile. But if I avoid using an alias, the same function can infer all arguments. Is this working as intended or have I

Re: Implicit Template Parameters Cannot Decipher Aliases?

2018-04-25 Thread Vijay Nayar via Digitalmars-d-learn
On Wednesday, 25 April 2018 at 07:39:28 UTC, Vijay Nayar wrote: addAllWithAlias(v1); // Error! One more note, this following line works correctly. addAllWithAlias!double(v1); // OK.

Re: Implicit Template Parameters Cannot Decipher Aliases?

2018-04-25 Thread Vijay Nayar via Digitalmars-d-learn
On Wednesday, 25 April 2018 at 10:25:11 UTC, Simen Kjærås wrote: In the general case, the issue is unsolvable, since the relationship between template parameters and alias results may be arbitrarily complex. A simple degenerate case is this: Ok, wow, you weren't kidding. That becomes really

Re: assigment to null class object member compiled? is this a bug?

2018-10-19 Thread Vijay Nayar via Digitalmars-d-learn
On Friday, 19 October 2018 at 06:53:32 UTC, dangbinghoo wrote: hi, why the code bellow compiles? --- import std.stdio; class A { int m; } void main() { A a; a.m = 1; } --- and running this code get: `segmentation fault (core dumped) ./test` I consider this couldn't be compiled

Re: Can Scope Be Used for Anonymous Objects?

2018-10-17 Thread Vijay Nayar via Digitalmars-d-learn
On Wednesday, 17 October 2018 at 20:41:24 UTC, Ali Çehreli wrote: On 10/17/2018 01:24 PM, Vijay Nayar wrote: I have a snippet of code like this:     scope chordAngle = new S1ChordAngle(_center, other._center);     return _radius + other._radius >= chordAngle; The reason the "scope"

Re: Can Scope Be Used for Anonymous Objects?

2018-10-17 Thread Vijay Nayar via Digitalmars-d-learn
On Wednesday, 17 October 2018 at 20:51:29 UTC, Stanislav Blinov wrote: On Wednesday, 17 October 2018 at 20:24:56 UTC, Vijay Nayar wrote: I have a snippet of code like this: scope chordAngle = new S1ChordAngle(_center, other._center); return _radius + other._radius >= chordAngle; The

Can Scope Be Used for Anonymous Objects?

2018-10-17 Thread Vijay Nayar via Digitalmars-d-learn
I have a snippet of code like this: scope chordAngle = new S1ChordAngle(_center, other._center); return _radius + other._radius >= chordAngle; The reason the "scope" temporary variable exists is to avoid a heap allocation and instead prefer a value be created on the stack. Is there a

Re: New With Struct and Getting Class Object Pointers

2018-10-03 Thread Vijay Nayar via Digitalmars-d-learn
On Sunday, 30 September 2018 at 11:11:09 UTC, Nicholas Wilson wrote: On Sunday, 30 September 2018 at 09:30:38 UTC, Vijay Nayar wrote: Is there a way to either have a constant reference to a class that can be set to a new value, or is there a way to convert the class variable to a class

New With Struct and Getting Class Object Pointers

2018-09-30 Thread Vijay Nayar via Digitalmars-d-learn
I have two brief questions. Code that uses "new" to create struct objects appears to compile and run. Is this an actual language feature, to get structs on the heap? void main() { struct S {int data = 1;} S* s1 = new S(); S* s2 = s1; S s3 = *s1; // Still

Re: New With Struct and Getting Class Object Pointers

2018-09-30 Thread Vijay Nayar via Digitalmars-d-learn
On Sunday, 30 September 2018 at 09:16:42 UTC, Nicholas Wilson wrote: On Sunday, 30 September 2018 at 07:29:00 UTC, Vijay Nayar wrote: Second question. const class variables may not be re-assigned, so if you need a variable that may be reassigned, but may never modify the underlying object, a

Re: New With Struct and Getting Class Object Pointers

2018-09-30 Thread Vijay Nayar via Digitalmars-d-learn
On Sunday, 30 September 2018 at 10:28:25 UTC, Alex wrote: On Sunday, 30 September 2018 at 09:30:38 UTC, Vijay Nayar wrote: Is there a way to either have a constant reference to a class that can be set to a new value, or is there a way to convert the class variable to a class pointer? I

Re: What is the Utility of Parent Class Method Hiding in Inheritance?

2019-01-16 Thread Vijay Nayar via Digitalmars-d-learn
On Wednesday, 16 January 2019 at 17:01:06 UTC, Steven Schveighoffer wrote: On 1/14/19 2:30 PM, Neia Neutuladh wrote: On Mon, 14 Jan 2019 09:10:39 +, Vijay Nayar wrote: a.foo(1); // issues runtime error (instead of calling A.foo(int)) Calling the function doesn't issue any sort of

Re: Best Way to Pass Template Typed Alias Parameters for Functions?

2018-12-23 Thread Vijay Nayar via Digitalmars-d-learn
On Sunday, 23 December 2018 at 18:31:24 UTC, Alex wrote: On Sunday, 23 December 2018 at 18:13:25 UTC, Vijay Nayar wrote: For example, if you have a const function in your container like "T find() const", and this function needs to use that comparator, then you're out of luck because the

Best Way to Pass Template Typed Alias Parameters for Functions?

2018-12-23 Thread Vijay Nayar via Digitalmars-d-learn
I have a few cases where I would like to pass in a function as a value to a template, but I want to ensure that the function takes certain kinds of parameters, is a const function, or matches any other set of conditions. What is the best way to do this? Just to avoid any potential confusion,

Re: Best Way to Pass Template Typed Alias Parameters for Functions?

2018-12-23 Thread Vijay Nayar via Digitalmars-d-learn
On Sunday, 23 December 2018 at 19:10:06 UTC, Alex wrote: On Sunday, 23 December 2018 at 18:53:15 UTC, Vijay Nayar wrote: You're right, it does compile. I'm a bit surprised. I wonder if this is a relatively recent improvement in the language, because last time I ran into this I had no such

Re: Best Way to Pass Template Typed Alias Parameters for Functions?

2018-12-23 Thread Vijay Nayar via Digitalmars-d-learn
On Sunday, 23 December 2018 at 18:04:32 UTC, Alex wrote: On Sunday, 23 December 2018 at 17:13:49 UTC, Vijay Nayar wrote: I have a few cases where I would like to pass in a function as a value to a template, but I want to ensure that the function takes certain kinds of parameters, is a const

Re: DConf 2019: Shepherd's Pie Edition

2018-12-24 Thread Vijay Nayar via Digitalmars-d-announce
On Saturday, 22 December 2018 at 12:18:25 UTC, Mike Parker wrote: Thanks to Symmetry Investments, DConf is heading to London! We're still ironing out the details, but I've been sitting on this for weeks and, now that we have a venue, I just can't keep quiet about it any longer. Looking

Re: Using D for AWS Beanstalk applications (German)

2018-11-28 Thread Vijay Nayar via Digitalmars-d-announce
On Tuesday, 27 November 2018 at 21:39:42 UTC, Andre Pany wrote: Hi, Find here a short tutorial how you can directly execute D applications on AWS Beanstalk. http://d-land.sepany.de/tutorials/cloud/native-aws-beanstalk-applikation/ Kind regards Andre I would never have believed that it

S2 Geometric Library for D

2018-12-10 Thread Vijay Nayar via Digitalmars-d-announce
I would like to announce the release of the S2 Geometric Library in the D Programming Language. Who: This is of interest to engineers who need to process very large amounts of geographic coordinate data very quickly. E.g. ride-shares, bikes, maps, etc. What: The S2 Geometric Library was

Re: How do you debug @safe @nogc code? Can't figure out how to print.

2018-11-22 Thread Vijay Nayar via Digitalmars-d-learn
On Sunday, 18 November 2018 at 11:00:26 UTC, aliak wrote: On Saturday, 17 November 2018 at 21:56:23 UTC, Neia Neutuladh wrote: On Sat, 17 Nov 2018 21:16:13 +, aliak wrote: [...] I meant something like: void debugln(T...)(T args) @nogc { import std.stdio;

Re: Converting an integer to a string with std.format.

2019-01-07 Thread Vijay Nayar via Digitalmars-d-learn
On Sunday, 6 January 2019 at 21:53:31 UTC, Per Nordlöw wrote: When converting a single integer to a string is `formatValue` preferred over `formattedWrite` in terms of compilation and run-time performance? Also, if you do not need to write to a stream or a range and just need the value,

What is the Utility of Parent Class Method Hiding in Inheritance?

2019-01-14 Thread Vijay Nayar via Digitalmars-d-learn
https://dlang.org/spec/function.html#function-inheritance Consider this snippet from the documentation: class A { int foo(int x) { ... } int foo(long y) { ... } } class B : A { override int foo(long x) { ... } } void test() { B b = new B(); b.foo(1); // calls B.foo(long),

Re: DCD, D-Scanner and DFMT : new year edition

2018-12-31 Thread Vijay Nayar via Digitalmars-d-announce
On Monday, 31 December 2018 at 07:56:00 UTC, Basile B. wrote: DCD [1] 0.10.2 comes with bugfixes and small API changes. DFMT [2] and D-Scanner [3] with bugfixes too and all of the three products are based on d-parse 0.10.z, making life easier and the libraries versions more consistent for the

Re: The New Fundraising Campaign

2019-01-02 Thread Vijay Nayar via Digitalmars-d-announce
On Wednesday, 2 January 2019 at 13:30:34 UTC, Martin Tschierschke wrote: On Wednesday, 2 January 2019 at 13:07:23 UTC, Joakim Brännström wrote: On Wednesday, 2 January 2019 at 10:16:11 UTC, Martin Tschierschke wrote: This campaign will end in 43 day, so the question after app. 50% is, what

Re: Blog post: What D got wrong

2018-12-19 Thread Vijay Nayar via Digitalmars-d-announce
On Wednesday, 12 December 2018 at 07:44:12 UTC, Walter Bright wrote: On 12/11/2018 4:51 AM, Nicholas Wilson wrote: > Returning a reference Wow, thats f*ck'n stupid! https://run.dlang.io/is/SAplYw It's quite deliberate. ref in C++ is a type constructor, but it's so special-cased to behave

Re: How to attach function attributes to delegate type?

2019-03-01 Thread Vijay Nayar via Digitalmars-d-learn
On Wednesday, 27 February 2019 at 20:45:33 UTC, Alex wrote: On Wednesday, 27 February 2019 at 20:03:15 UTC, Q. Schroll wrote: For any type constructors like const, I can use ConstOf!T to get `T` with const attached. For a delegate/function type DG, e.g. int delegate(int), how can I get the

Re: DIP 1000--Scoped Pointers--Superseded

2019-03-07 Thread Vijay Nayar via Digitalmars-d-announce
On Thursday, 7 March 2019 at 11:30:01 UTC, Mike Parker wrote: As most of you surely know, DIP 1000, "Scoped Pointers", has been sitting in the DIP queue with the Draft status for ages and was significantly out of sync with the implementation. When I first took over as DIP Manager, the initial

Re: LDC 1.15.0

2019-04-10 Thread Vijay Nayar via Digitalmars-d-announce
On Saturday, 6 April 2019 at 17:40:39 UTC, kinke wrote: Glad to announce LDC 1.15: * Based on D 2.085.1. * Support for LLVM 8.0. The prebuilt packages ship with LLVM 8.0.0 and include the Khronos SPIRV-LLVM-Translator, so that dcompute can now emit OpenCL too. * New -lowmem switch to enable

S2Geometry Library Release v0.2

2019-05-25 Thread Vijay Nayar via Digitalmars-d-announce
Greetings everyone. I wanted to announce here the v0.2 release of the S2 Geometry Library in the D language. The DUB page should be updated to show v0.2 shortly. https://code.dlang.org/packages/s2geometry-d What is it? = The S2 Geometry library is an extremely high precision and

Re: S2Geometry Library Release v0.2

2019-05-25 Thread Vijay Nayar via Digitalmars-d-announce
On Saturday, 25 May 2019 at 19:34:50 UTC, Sebastiaan Koppe wrote: On Saturday, 25 May 2019 at 11:48:12 UTC, Vijay Nayar wrote: D's philosophy of having a large tool-box makes this work doable by a single person while other languages have spent many years with many contributors. Great work!

Re: S2Geometry Library Release v0.2

2019-05-25 Thread Vijay Nayar via Digitalmars-d-announce
On Saturday, 25 May 2019 at 11:48:12 UTC, Vijay Nayar wrote: I wanted to announce here the v0.2 release of the S2 Geometry Library in the D language. The DUB page should be updated to show v0.2 shortly. https://code.dlang.org/packages/s2geometry-d Today I learned that released versions must

Re: Searching for Dgame Maintainer

2019-11-25 Thread Vijay Nayar via Digitalmars-d-announce
On Sunday, 24 November 2019 at 16:34:35 UTC, Dgame wrote: Maybe some of you know Dgame (https://github.com/Dgame/Dgame), it was my biggest project using D and was a lot of fun at that time. But since I don't use D anymore, I have neither the time nor the desire and even less the knowledge to

Re: The ABC's of Templates in D

2020-08-07 Thread Vijay Nayar via Digitalmars-d-announce
On Friday, 31 July 2020 at 13:46:43 UTC, Mike Parker wrote: The blog: https://dlang.org/blog/2020/07/31/the-abcs-of-templates-in-d/ This is very well written! I want to share it with my coworkers using Java to see if it piques their interest.

Re: Release: avro-d v0.1.0

2022-03-16 Thread Vijay Nayar via Digitalmars-d-announce
On Wednesday, 9 March 2022 at 14:26:10 UTC, Vijay Nayar wrote: The initial v0.1.0 of the Avro library in D can be found here: https://code.dlang.org/packages/avro-d Version 0.2.2 has been released, which includes the ability to read and write generic objects in JSON format in addition to the

Release: avro-d v0.1.0

2022-03-09 Thread Vijay Nayar via Digitalmars-d-announce
Greetings D Community, Do you have need for an efficient binary format for encoding and decoding data, but are hesitant to use things like [Google Protocol Buffers](https://developers.google.com/protocol-buffers) due to the need to re-compile code in order to change formats? [Apache

DDoc Reference Links point to /docs/docs instead of /docs?

2022-02-21 Thread Vijay Nayar via Digitalmars-d-learn
Greetings everyone, I have a question regarding the use of [relative links](https://dlang.org/spec/ddoc.html#reference_links) in DDoc. According to the specification, you can include a reference to an object that is in scope using square brackets, e.g. `[Object]`. One of my current projects

Function Parameters without Names?

2022-02-19 Thread Vijay Nayar via Digitalmars-d-learn
I encountered an odd bug in a project of mine which is illustrated in the example below: ```d class Thing { int val; this(int) { this.val = val; } } void main() { auto t = new Thing(3); assert(t.val != 3); } ``` The problem is that the parameter of the constructor actually has

Re: Detecting ElementType of OutputRange

2022-02-26 Thread Vijay Nayar via Digitalmars-d-learn
On Saturday, 26 February 2022 at 11:44:35 UTC, Stanislav Blinov wrote: https://dlang.org/phobos/std_range_primitives.html#isOutputRange This method requires the caller to explicitly declare the output range element type, which I was hoping to have to avoid, if it can be detected using

Re: Detecting ElementType of OutputRange

2022-02-26 Thread Vijay Nayar via Digitalmars-d-learn
On Saturday, 26 February 2022 at 12:39:51 UTC, Stanislav Blinov wrote: Considering that `put` is quite typically implemented as a template, I don't think that would be possible in general. That is what I found as well, for example, the implementation of `put` from `Appender` and

Re: Cannot Call Super-Class Overloaded Function If Class has Function Override?

2022-03-01 Thread Vijay Nayar via Digitalmars-d-learn
On Tuesday, 1 March 2022 at 09:06:59 UTC, vit wrote: On Tuesday, 1 March 2022 at 08:40:12 UTC, Vijay Nayar wrote: I've randomly encountered a strange error, and I cannot find any explanation for it in the official documentation of syntax. [...] Here is more info (3.):

Cannot Call Super-Class Overloaded Function If Class has Function Override?

2022-03-01 Thread Vijay Nayar via Digitalmars-d-learn
I've randomly encountered a strange error, and I cannot find any explanation for it in the official documentation of syntax. Essentially, a class cannot call function overload in a super-class if the class itself contains an override. Is this a bug? Is this on purpose? Take a look at

Re: DDoc Reference Links point to /docs/docs instead of /docs?

2022-02-21 Thread Vijay Nayar via Digitalmars-d-learn
On Monday, 21 February 2022 at 16:58:43 UTC, Adam D Ruppe wrote: On Monday, 21 February 2022 at 15:35:41 UTC, Vijay Nayar wrote: I'm a bit surprised I've never heard of `adrdox` before now. yeah i don't advertise much. it is what runs on my dpldocs.info website though which auto-generates

Re: DDoc Reference Links point to /docs/docs instead of /docs?

2022-02-21 Thread Vijay Nayar via Digitalmars-d-learn
On Monday, 21 February 2022 at 13:18:01 UTC, Adam D Ruppe wrote: tbh ddoc is pretty bad, you should try my `dub run adrdox` instead which also creates html but its links actually work. I gave it a try and I must say that the documentation is formatted in a very good way, and as you said, all

Detecting ElementType of OutputRange

2022-02-26 Thread Vijay Nayar via Digitalmars-d-learn
I was working on a project where it dealt with output ranges, but these ranges would ultimately sink into a source that would be inefficient if every single `.put(T)` call was made one at a time. Naturally, I could make a custom OutputRange for just this resource, but I also got the idea that

Re: How to create delegates with an independent scope?

2022-03-30 Thread Vijay Nayar via Digitalmars-d-learn
On Wednesday, 30 March 2022 at 12:53:10 UTC, vit wrote: use two delegates :) ```d (){ // Deliberately create a copy to keep in delegate scope. string myStr = i.dup; // The delegate will hopefully carry this copy around in its own

How to create delegates with an independent scope?

2022-03-30 Thread Vijay Nayar via Digitalmars-d-learn
Consider the following code example: ```d import std.stdio; void main() { alias DelegateT = string delegate(); // An array of delegates, each has their own scope. DelegateT[] funcs; foreach (i; ["ham", "cheese"]) { // Deliberately create a copy to keep in delegate scope. string

Can std.variant be used with std.container.rbtree?

2022-04-01 Thread Vijay Nayar via Digitalmars-d-learn
Consider the following program: ```d void main() { import std.stdio; import std.container.rbtree; import std.variant; // alias Type = int; // Works with no problem. alias Type = Variant; // Produces error. auto rbTree = new RedBlackTree!(Type);

Re: Can std.variant be used with std.container.rbtree?

2022-04-02 Thread Vijay Nayar via Digitalmars-d-learn
On Saturday, 2 April 2022 at 10:03:19 UTC, JG wrote: You need an order on the elements in a red black tree. Am I correct in thinking you want a container of the form given a key (a string) recover some data (of different types). If so make the elements you store in the red black tree tuples

Re: Can std.variant be used with std.container.rbtree?

2022-04-02 Thread Vijay Nayar via Digitalmars-d-learn
On Saturday, 2 April 2022 at 14:23:31 UTC, Salih Dincer wrote: If your type includes opCmp() there is no reason not to use rbTree. I am using rbTree, the problem is when I try to use it with Variant, at which point it blows up.

Re: Can std.variant be used with std.container.rbtree?

2022-04-02 Thread Vijay Nayar via Digitalmars-d-learn
On Saturday, 2 April 2022 at 10:04:49 UTC, vit wrote: Try use ```std.sumtype```. I'm playing with SumType to see how it works, and I must be doing something silly, because it fails to compile with the first example type I attempted. Consider the following: ```d import std.sumtype; import

Re: Can std.variant be used with std.container.rbtree?

2022-04-02 Thread Vijay Nayar via Digitalmars-d-learn
On Saturday, 2 April 2022 at 14:35:10 UTC, Vijay Nayar wrote: The `tryMatch` method fails to compile, and instead I get the following error: ```d /dlang/dmd/linux/bin64/../../src/phobos/std/sumtype.d(2004): Error: static assert: "`handlers[0]` of type `int function(ref ubyte[] _1, ref

Re: How to make dub recursively build subPackages?

2022-02-02 Thread Vijay Nayar via Digitalmars-d-learn
On Wednesday, 2 February 2022 at 10:14:25 UTC, Vijay Nayar wrote: Greetings folks, In my project, I have a parent package with several sub-packages, each of which builds into either a library or an executable. [...] I should point out there is 1 exception to subPackages not being

How to make dub recursively build subPackages?

2022-02-02 Thread Vijay Nayar via Digitalmars-d-learn
Greetings folks, In my project, I have a parent package with several sub-packages, each of which builds into either a library or an executable. I first started observing odd problems when I was running `dub build`, it would complain about different versions of vibe-d present, and it

Re: How to make dub recursively build subPackages?

2022-02-02 Thread Vijay Nayar via Digitalmars-d-learn
On Wednesday, 2 February 2022 at 14:07:08 UTC, Steven Schveighoffer wrote: On 2/2/22 5:14 AM, Vijay Nayar wrote: If you have them in the same repository, my recommendation is to use path dependencies instead of versions. So, e.g.: ```sdl dependency "funnel:proto" path="./proto" // in main

Re: How to make dub recursively build subPackages?

2022-02-02 Thread Vijay Nayar via Digitalmars-d-learn
On Wednesday, 2 February 2022 at 19:03:35 UTC, Steven Schveighoffer wrote: On 2/2/22 1:42 PM, Vijay Nayar wrote: Dub is kind of a hot mess in terms of the dependency resolution and ways to specify projects. I would love to see it cleaned up/reimplemented. -Steve For your larger more

Approach to Integration Testing in D

2022-02-04 Thread Vijay Nayar via Digitalmars-d-learn
Greetings everyone, ## Question What is your approach to integration testing in D? Do you use `unittest` blocks? Do you write stand-alone programs that interact with a running version of your program? Is there a library that makes certain kinds of testing easier? For example, if I have a D

Re: Approach to Integration Testing in D

2022-02-06 Thread Vijay Nayar via Digitalmars-d-learn
On Friday, 4 February 2022 at 17:39:00 UTC, H. S. Teoh wrote: On Fri, Feb 04, 2022 at 12:38:08PM +, Vijay Nayar via Digitalmars-d-learn wrote: [...] I am still in the process of experimenting, but the advice on this thread has all been very helpful. Right now I'm experimenting

Re: Approach to Integration Testing in D

2022-02-06 Thread Vijay Nayar via Digitalmars-d-learn
On Sunday, 6 February 2022 at 17:36:05 UTC, Vijay Nayar wrote: On Friday, 4 February 2022 at 17:39:00 UTC, H. S. Teoh wrote: On Fri, Feb 04, 2022 at 12:38:08PM +, Vijay Nayar via When working on a dub configuration needed to separately run integration tests that operate on the fully

Re: vibe.d requestHTTP in static this causes infinite loop?

2022-05-20 Thread Vijay Nayar via Digitalmars-d-learn
On Friday, 20 May 2022 at 01:41:59 UTC, Ali Çehreli wrote: On 5/19/22 16:44, Vijay Nayar wrote: > If I remove the call from `static this()`, then the web call works as > normal. Any idea why calling vibe.d's `requestHTTP` function inside of a > module's static construction would cause an

vibe.d requestHTTP in static this causes infinite loop?

2022-05-19 Thread Vijay Nayar via Digitalmars-d-learn
I've encountered an unusual behavior that I have no good explanation for. Consider the following code example: ```d import vibe.core.log : logInfo; import vibe.http.client : requestHTTP, HTTPClientRequest, HTTPClientResponse; import vibe.http.common : HTTPMethod; import vibe.stream.operations

Re: Vibe.d v0.9.5 released!

2022-07-18 Thread Vijay Nayar via Digitalmars-d-announce
On Monday, 18 July 2022 at 16:07:02 UTC, Mathias LANG wrote: Hi everyone, A new version of Vibe.d has been released today. You can see the list of changes [on Github](https://github.com/vibe-d/vibe.d/releases/tag/v0.9.5). Of particular interest to me is the bump of the deimos/OpenSSL

Re: Best practice for dub registry package and module names

2022-09-07 Thread Vijay Nayar via Digitalmars-d-learn
On Sunday, 4 September 2022 at 01:52:11 UTC, Ali Çehreli wrote: Let's say I have three modules that work together, which I want to register on dub: A, B, and C. Here I would take inspiration from the Java world, where a "domain" is used per project. Typically this domain is written from

Re: Error "Outer Function Context is Needed" when class declared in unittest

2023-01-05 Thread Vijay Nayar via Digitalmars-d-learn
On Thursday, 5 January 2023 at 16:41:32 UTC, Adam D Ruppe wrote: On Thursday, 5 January 2023 at 16:38:49 UTC, Vijay Nayar wrote: Does that class inherit the scope of the function it is inside, similar to how an inner class does with an outer class? yup. They can see the local variables from

Builder: Tiny Utility Library to Add a Builder API to Classes

2023-01-05 Thread Vijay Nayar via Digitalmars-d-announce
https://code.dlang.org/packages/builder Interacting with many projects that are related to Java, I could not help notice that a common "Builder API" is not easily available in D. What is the problem? When constructing classes, especially those with lots of data, there are two broad ways of

Re: Error "Outer Function Context is Needed" when class declared in unittest

2023-01-05 Thread Vijay Nayar via Digitalmars-d-learn
On Thursday, 5 January 2023 at 13:47:24 UTC, Adam D Ruppe wrote: On Thursday, 5 January 2023 at 13:27:23 UTC, Vijay Nayar wrote: Why is this error only found when declaring a class in the unittest? A unittest is just a special function, it can run code and have local variables. classes and

Re: Builder: Tiny Utility Library to Add a Builder API to Classes

2023-01-06 Thread Vijay Nayar via Digitalmars-d-announce
On Friday, 6 January 2023 at 09:26:51 UTC, thebluepandabear wrote: .isActive(true) .build(); ``` Good  how would I extend the builder methods? The builder methods are automatically generated and go up the inheritance chain to capture all the fields in your class. (I assume that you

Re: Builder: Tiny Utility Library to Add a Builder API to Classes

2023-01-06 Thread Vijay Nayar via Digitalmars-d-announce
On Thursday, 5 January 2023 at 23:31:36 UTC, Vladimir Marchevsky wrote: On Thursday, 5 January 2023 at 21:48:40 UTC, Vijay Nayar wrote: 2. Using a constructor with many arguments. ``` A a = new A("Bob", 20, false, true); ``` This approach can construct arguments inline, such as during a

OpenAPI Client Generator

2023-01-02 Thread Vijay Nayar via Digitalmars-d-announce
I would like to put an announcement for two new projects added to https://code.dlang.org. https://code.dlang.org/packages/openapi-client This project is an executable that reads an [OpenAPI Specification](https://spec.openapis.org/oas/latest.html) in JSON format and writes a D client to

Error "Outer Function Context is Needed" when class declared in unittest

2023-01-05 Thread Vijay Nayar via Digitalmars-d-learn
I've run into an unexpected problem that only seems to happen in unittests, but not outside of them. Consider the following example: ``` unittest { class Ab { int a; string b; static class Builder { int _a; string _b; Builder a(int a) { _a = a;

Re: class variable initialization

2023-04-15 Thread Vijay Nayar via Digitalmars-d-learn
On Saturday, 15 April 2023 at 14:05:17 UTC, NonNull wrote: I want a way to default initialize a class variable to a default object (e.g. by wrapping it in a struct, because initialization to null cannot be changed directly). Such a default object is of course not available at compile time

  1   2   >