Re: Placement new and @trusted

2025-09-17 Thread IchorDev via Digitalmars-d-learn
On Wednesday, 10 September 2025 at 14:45:52 UTC, Richard (Rikki) Andrew Cattermole wrote: The caller is responsible for guaranteeing that the memory passed in is uninitialized, and that behavior is @system. Yeah but I should be able to mark it as `@trusted` without trusting some random bloody

Re: Explain function syntax

2025-09-17 Thread Paul Backus via Digitalmars-d-learn
On Wednesday, 17 September 2025 at 22:16:50 UTC, Brother Bill wrote: Then there is another example with 'delegate' instead of 'function. ``` import std.stdio; void main() { } alias Calculator = int function(int); Calculator makeCalculator() { int increment = 10; return value

Re: Debug help - delegate from dlang Tour

2025-09-17 Thread evilrat via Digitalmars-d-learn
On Monday, 8 September 2025 at 14:32:32 UTC, Brother Bill wrote: https://tour.dlang.org/tour/en/basics/delegates This is so simple. What is D complaining about? Should this also work with a Template, as shown? ``` import std.stdio; void main() { // auto add(T)(T lhs, T rhs) //

Re: Placement new and @trusted

2025-09-17 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
Ok, gotcha. Placement new is @system, but you wanted to use it in an @safe function iff the constructor to be called is @safe as well. The reason placement new is @system is because of double-init. It can't be a safe operation.

Re: Explain function syntax

2025-09-17 Thread H. S. Teoh via Digitalmars-d-learn
On Wed, Sep 17, 2025 at 10:16:50PM +, Brother Bill via Digitalmars-d-learn wrote: > In the following from Programming in D, page 483, we use function keyword. > > I expect that the first int in > ``` > int function(int); > ``` > > represents the return value. > > What does the second (int)

Re: Explain function syntax

2025-09-17 Thread monkyyy via Digitalmars-d-learn
On Wednesday, 17 September 2025 at 22:16:50 UTC, Brother Bill wrote: ``` import std.stdio; void main() { } alias Calculator = int function(int); Calculator makeCalculator() { int increment = 10; return value => increment + value; // ← compilation ERROR } ``` function is alm

Explain function syntax

2025-09-17 Thread Brother Bill via Digitalmars-d-learn
In the following from Programming in D, page 483, we use function keyword. I expect that the first int in ``` int function(int); ``` represents the return value. What does the second (int) refer to? Then there is another example with 'delegate' instead of 'function. ``` import std.stdio;

Re: Debug help - delegate from dlang Tour

2025-09-17 Thread Brother Bill via Digitalmars-d-learn
This works: ``` import std.stdio; void main() { foo(); } void foo() { int addMyInts(int lhs, int rhs) { return lhs + rhs; } int doSomething(int delegate(int, int) doer) { // call passed function return doer(

Re: Cleared AA == and is have different results. Why?

2025-09-17 Thread Brother Bill via Digitalmars-d-learn
On Wednesday, 10 September 2025 at 14:25:05 UTC, IchorDev wrote: On Wednesday, 10 September 2025 at 14:01:29 UTC, Brother Bill wrote: what is the meanings of == null vs. is null? You have already asked this question [here before](https://forum.dlang.org/thread/nvaiwzvcrahnwzior...@forum.dlang

Re: Preventing .init for Archive struct, Programming in D, page 295

2025-09-17 Thread Dejan Lekic via Digitalmars-d-learn
On Friday, 12 September 2025 at 15:20:38 UTC, Brother Bill wrote: Is is possible to 'disable' .init for a struct? You do not want .init? Fine: ```d Archive noInit = void; ```

Re: Placement new and @trusted

2025-09-17 Thread Paul Backus via Digitalmars-d-learn
On Thursday, 11 September 2025 at 11:47:40 UTC, Dennis wrote: On Wednesday, 10 September 2025 at 12:29:24 UTC, IchorDev wrote: If anyone has any ideas, please let me know. The trick that's used in druntime is putting the part that still needs to be checked for attributes inside an `if (false)

Re: understanding mir, generic nd array iterator

2025-09-17 Thread jmh530 via Digitalmars-d-learn
On Wednesday, 17 September 2025 at 14:57:19 UTC, monkyyy wrote: [snip] Sorry, I'm having trouble understanding what you're trying to do.

Re: Preventing .init for Archive struct, Programming in D, page 295

2025-09-17 Thread Monkyyy via Digitalmars-d-learn
On Friday, 12 September 2025 at 15:20:38 UTC, Brother Bill wrote: Is is possible to 'disable' .init for a struct? No (and honestly it's bad style to break the constructors)

Re: Microsoft chose Go instead of C# or Rust to rewrite TypeScript

2025-09-17 Thread Ali Çehreli via Digitalmars-d-learn
On 9/8/25 12:55 PM, Neto wrote: > On Monday, 8 September 2025 at 16:51:09 UTC, Serg Gini wrote: >> On Monday, 8 September 2025 at 16:43:10 UTC, Neto wrote: >> Yes, I know there are companies that are using it in production. >> Even several big ones like Weka and Symmetry. > Why isn't D productio

Re: understanding mir, generic nd array iterator

2025-09-17 Thread jmh530 via Digitalmars-d-learn
On Wednesday, 10 September 2025 at 20:23:28 UTC, monkyyy wrote: [snip] Documentation for mir iterators is here: http://mir-algorithm.libmir.org/mir_ndslice_iterator.html If you want to use mir without using the GC. You can allocate with malloc, custom allocator, or use an RC allocator. http:

Re: understanding mir, generic nd array iterator

2025-09-17 Thread monkyyy via Digitalmars-d-learn
On Wednesday, 17 September 2025 at 12:06:32 UTC, jmh530 wrote: On Wednesday, 10 September 2025 at 20:23:28 UTC, monkyyy wrote: [snip] Documentation for mir iterators is here: http://mir-algorithm.libmir.org/mir_ndslice_iterator.html I see nd-iota but it seems under powered(handling only the