Re: Can I create a package with friendly modules

2022-06-12 Thread Salih Dincer 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. For this to be possible: You must first collect all modules in the directory with the sam

Re: Generating unique identifiers at compile time

2022-06-12 Thread JG via Digitalmars-d-learn
On Friday, 10 June 2022 at 06:17:54 UTC, bauss wrote: On Thursday, 9 June 2022 at 23:50:10 UTC, user1234 wrote: There's [been attempts] to expose it, exactly so that users can generate unique names, but that did not found its path in the compiler. [been attempts]: https://github.com/dlang/d

Re: Generating unique identifiers at compile time

2022-06-12 Thread Paul Backus via Digitalmars-d-learn
On Thursday, 9 June 2022 at 21:20:27 UTC, JG wrote: In doing so I wanted to produce unique identifiers (something like gensym in racket.) I did this in a very hacky way: [...] Is there some way to ask the compiler for a unique name or a better way of achieving this? Here's a `gensym` implemen

Re: Generating unique identifiers at compile time

2022-06-12 Thread JG via Digitalmars-d-learn
On Sunday, 12 June 2022 at 18:45:27 UTC, Paul Backus wrote: On Thursday, 9 June 2022 at 21:20:27 UTC, JG wrote: [...] [...] [...] Here's a `gensym` implementation I came up with a while back: ```d enum gensym = q{"_gensym" ~ __traits(identifier, {})["__lambda".length .. $]}; // Works mul

Re: Comparing Exceptions and Errors

2022-06-12 Thread kdevel via Digitalmars-d-learn
On Tuesday, 7 June 2022 at 18:37:13 UTC, Steven Schveighoffer wrote: [...] My very common use of `scope(failure)` for my DB code: ```d conn.exec("START TRANSACTION"); scope(success) conn.exec("COMMIT"); scope(failure) conn.exec("ROLLBACK"); ``` Are there multiple (successful) returns in your

Re: Comparing Exceptions and Errors

2022-06-12 Thread kdevel via Digitalmars-d-learn
On Sunday, 5 June 2022 at 23:57:19 UTC, Steven Schveighoffer wrote: On 6/5/22 6:09 PM, kdevel wrote: On Sunday, 5 June 2022 at 20:53:32 UTC, Steven Schveighoffer wrote: [...] For this purpose nobody needs a separate subclass named `Error`. That works with `Exception`s. You can use Exceptions

Re: map! evaluates twice

2022-06-12 Thread Antonio via Digitalmars-d-learn
On Friday, 10 June 2022 at 20:47:14 UTC, Steven Schveighoffer wrote: On 6/10/22 4:33 PM, Antonio wrote: ... `map` calls the lambda for each call to `front`. If you want a cached version, use `cache`: Thank you very much, Steve

Re: Can I create a package with friendly modules

2022-06-12 Thread forkit via Digitalmars-d-learn
On Sunday, 12 June 2022 at 05:46:17 UTC, Mike Parker wrote: I don't get it. How does this enable one module to access the private parts of another module? Isn't 'private' *always* private to the module? The idea I had, was to be able to spread a 'module' over more than one file - for the

Re: Can I create a package with friendly modules

2022-06-12 Thread Mike Parker via Digitalmars-d-learn
On Sunday, 12 June 2022 at 23:29:29 UTC, forkit wrote: I don't get it. How does this enable one module to access the private parts of another module? It doesn't. But what you were describing in your post is package-level access. By keeping it the cross-module access in a subpackage, packa

Re: Can I create a package with friendly modules

2022-06-12 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