Re: dub run subPackage by default

2020-09-01 Thread Andre Pany via Digitalmars-d-learn
On Tuesday, 1 September 2020 at 19:38:39 UTC, ParticlePeter wrote: On Tuesday, 1 September 2020 at 14:45:43 UTC, Andre Pany wrote: On Tuesday, 1 September 2020 at 11:45:34 UTC, ParticlePeter wrote: [snip] I have a enhancement for dub in my mind, which would also solve your issue. Similiar to

Re: Tuple poilerplate code

2020-09-01 Thread JG via Digitalmars-d-learn
Thank you all for the interesting suggestions.

Re: I think Associative Array should throw Exception

2020-09-01 Thread James Blachly via Digitalmars-d-learn
On 9/1/20 2:55 PM, Steven Schveighoffer wrote: On 9/1/20 2:20 PM, Jesse Phillips wrote: Using RangeError is nice as it allows code to use array index inside `nothrow.` This is the big sticking point -- code that is nothrow would no longer be able to use AAs. It makes the idea, unfortunately,

Re: BetterC + WASM Update

2020-09-01 Thread Mike Brown via Digitalmars-d-learn
Hi All, Thank you for your replies. My tests have been via compiler explorer. https://godbolt.org/z/4f9nKj I have done this without -BetterC, as the dynamic array fails. I guess that uses GC? Is there an alternative that works with BetterC for dynamic arrays? Thank you for the other WASM l

Re: dub run subPackage by default

2020-09-01 Thread ParticlePeter via Digitalmars-d-learn
On Tuesday, 1 September 2020 at 14:45:43 UTC, Andre Pany wrote: On Tuesday, 1 September 2020 at 11:45:34 UTC, ParticlePeter wrote: [snip] I have a enhancement for dub in my mind, which would also solve your issue. Similiar to setup.py in python you would be able to define an entry point in d

Re: How to create compile-time container?

2020-09-01 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/1/20 3:09 PM, Andrey Zherikov wrote: Unfortunately this won't work if there is a function 'bar' in different module that calls 'foo': You should post a full example you expect to work or not work, then we can discuss. I think it should work (I've tried it), but there are several problem

Re: I think Associative Array should throw Exception

2020-09-01 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 1 September 2020 at 18:55:20 UTC, Steven Schveighoffer wrote: This is the big sticking point -- code that is nothrow would no longer be able to use AAs. It makes the idea, unfortunately, a non-starter. You could always catch it though. But I kinda like things the way they are exac

Re: How to create compile-time container?

2020-09-01 Thread Andrey Zherikov via Digitalmars-d-learn
On Tuesday, 1 September 2020 at 18:19:55 UTC, Andrey Zherikov wrote: The thing I'm trying to implement is: I have a function foo(string s)() and some "state"; this function should override this "state" (using "s" param) for all code within this function (note that code can execute other modules

Re: How to create compile-time container?

2020-09-01 Thread Andrey Zherikov via Digitalmars-d-learn
On Tuesday, 1 September 2020 at 18:57:30 UTC, Steven Schveighoffer wrote: string overrideState(string s) { // work your magic here, it's normal D code! } void foo(string s)() { mixin(overrideState(s)); } Unfortunately this won't work if there is a function 'bar' in different module that

Re: How to create compile-time container?

2020-09-01 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/1/20 2:19 PM, Andrey Zherikov wrote: On Monday, 31 August 2020 at 20:44:16 UTC, Adam D. Ruppe wrote: On Monday, 31 August 2020 at 20:39:10 UTC, Andrey Zherikov wrote: How can I do that? You can use a normal string[] BUT it is only allowed to be modified inside its own function. Then y

Re: I think Associative Array should throw Exception

2020-09-01 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/1/20 2:20 PM, Jesse Phillips wrote: Using RangeError is nice as it allows code to use array index inside `nothrow.` This is the big sticking point -- code that is nothrow would no longer be able to use AAs. It makes the idea, unfortunately, a non-starter. What is wrong with using `in`?

I think Associative Array should throw Exception

2020-09-01 Thread Jesse Phillips via Digitalmars-d-learn
This is going to be a hard one for me to argue but I'm going to give it a try. Today if you attempt to access a key from an associative array (AA) that does not exist inside the array, a RangeError is thrown. This is similar to when an array is accessed outside the bounds. ``` string[string

Re: How to create compile-time container?

2020-09-01 Thread Andrey Zherikov via Digitalmars-d-learn
On Monday, 31 August 2020 at 20:44:16 UTC, Adam D. Ruppe wrote: On Monday, 31 August 2020 at 20:39:10 UTC, Andrey Zherikov wrote: How can I do that? You can use a normal string[] BUT it is only allowed to be modified inside its own function. Then you assign that function to an enum or whate

Re: dub run subPackage by default

2020-09-01 Thread Andre Pany via Digitalmars-d-learn
On Tuesday, 1 September 2020 at 11:45:34 UTC, ParticlePeter wrote: Hello, I have a targetType sourceLibrary and demonstrate its usage through a subPackage. For the library itself 'dub run' is meaningless, but not for the subPackage. Is there a way to tell dub through dub.sdl or dub.json to bui

Re: Tuple poilerplate code

2020-09-01 Thread WebFreak001 via Digitalmars-d-learn
On Tuesday, 1 September 2020 at 02:08:54 UTC, JG wrote: [...] Here is some fun with operator overloading and pointers, but I don't really like it because it seems unsafe: import std; auto _(T...)(return ref T refs) @safe { static struct Assigner(Ptrs...) { @disable this(this);

dub run subPackage by default

2020-09-01 Thread ParticlePeter via Digitalmars-d-learn
Hello, I have a targetType sourceLibrary and demonstrate its usage through a subPackage. For the library itself 'dub run' is meaningless, but not for the subPackage. Is there a way to tell dub through dub.sdl or dub.json to build and run a specific subPackage by default, without having to call

Re: Tuple poilerplate code

2020-09-01 Thread Simen Kjærås via Digitalmars-d-learn
On Tuesday, 1 September 2020 at 02:08:54 UTC, JG wrote: Is there anyway to remove the boilerplate code of dealing with tuples: I find myself having to write things like this fairly often auto someRandomName = f(...); //where f returns a tuple with two parts auto firstPart = someRandomName[0

Re: Tuple poilerplate code

2020-09-01 Thread Paul Backus via Digitalmars-d-learn
On Tuesday, 1 September 2020 at 02:08:54 UTC, JG wrote: Is there anyway to remove the boilerplate code of dealing with tuples: I find myself having to write things like this fairly often auto someRandomName = f(...); //where f returns a tuple with two parts auto firstPart = someRandomName[0

Re: Template argument deduction fails with alias

2020-09-01 Thread Paul Backus via Digitalmars-d-learn
On Tuesday, 1 September 2020 at 02:48:08 UTC, Ben Jones wrote: Thanks all. I tried using alias this at first and then I get errors trying to construct AliasType objects: auto pi = Payload!int(5); auto pe = ParseError("error"); alias PRType = ParseResult!(Payload!int, ParseError); auto pr =

Re: How package Dlang in a standalone portable executable?

2020-09-01 Thread Andre Pany via Digitalmars-d-learn
On Tuesday, 1 September 2020 at 01:29:43 UTC, Marcone wrote: I need package Dlang in a standalone portable executable. I need packcages all dependencies, dlls, files, etc in one executable file. Please see here https://p0nce.github.io/d-idioms/#Embed-a-dynamic-library-in-an-executable Kind re

Re: Tuple poilerplate code

2020-09-01 Thread JG via Digitalmars-d-learn
On Tuesday, 1 September 2020 at 03:51:10 UTC, user1234 wrote: On Tuesday, 1 September 2020 at 02:08:54 UTC, JG wrote: Is there anyway to remove the boilerplate code of dealing with tuples: I find myself having to write things like this fairly often auto someRandomName = f(...); //where f ret