On Monday, 25 August 2025 at 02:36:01 UTC, Brother Bill wrote:
also just factor it out and unit test it if its complex
On Sunday, 24 August 2025 at 14:40:36 UTC, Steven Schveighoffer
wrote:
```d
// solution 1: (preferred)
if(auto r = cast(MyInt)result){
writeln(r);
}else if(auto r = cast(MyFloat)result){
writeln(r);
}
// solution 2:
if(typeid(result) is typeid(MyInt)){
writeln(cast(MyInt)result);
}el
On 25/08/2025 2:36 PM, Brother Bill wrote:
Is there a way to see expanded templates/mixins as the D compile expands
it?
This would be nice for pedagogical purposes.
-mixin= expand and save mixins to file specified by
Is there a way to see expanded templates/mixins as the D compile
expands it?
This would be nice for pedagogical purposes.
On Sunday, 24 August 2025 at 20:43:15 UTC, Ali Çehreli wrote:
I think you went a little further in that section and made the
return 'auto ref', which does not (and should not) fail
compilation.
No. auto ref is only for templates. This is a bug and should not
compile.
-Steve
On Sunday, 24 August 2025 at 15:29:01 UTC, Steven Schveighoffer
wrote:
```
import std.stdio;
void main() {
string * ptrSum = &parenthesized("2 + 3");
string sum = parenthesized("4 * 5");
writefln("ptrSum : %s %s", ptrSum, *ptrSum);
writefln("sum: %s", sum);
}
auto ref s
On 8/24/25 11:17 AM, Brother Bill wrote:
> On Sunday, 24 August 2025 at 17:30:33 UTC, Ali Çehreli wrote:
>> In this case, you used the body of a 'ref' function but compiled it as
>> 'auto ref'. Please remove 'auto' above.
>>
>> Ali
>
> The book has 'auto ref' in "auto ref functions" section.
Yes.
On 8/24/25 11:29 AM, Brother Bill wrote:
> Ali, may I have a Yes or No on permission to use your Programming in D
> examples that I am expanding for a commercial Udemy course that I will
> build.
If this forum post is authoritative for you, yes, I give permission.
> Also, would now be a good ti
On Sunday, 24 August 2025 at 17:30:33 UTC, Ali Çehreli wrote:
First, thank you for reading the book and raising so many
issues. Very much appreciated!
Ali
Ali, may I have a Yes or No on permission to use your Programming
in D examples that I am expanding for a commercial Udemy course
that
On Sunday, 24 August 2025 at 13:59:46 UTC, Andrey Zherikov wrote:
On Wednesday, 20 August 2025 at 15:33:45 UTC, monkyyy wrote:
once again dconf contains people who talk about compile speed
as if it can be slow
What are they doing? Even my worse compile time abstraction
was O(n^2) or maybe som
On Sunday, 24 August 2025 at 17:30:33 UTC, Ali Çehreli wrote:
In this case, you used the body of a 'ref' function but
compiled it as 'auto ref'. Please remove 'auto' above.
Ali
The book has 'auto ref' in "auto ref functions" section.
Does your book need a change?
I'm not sure why we should re
On 8/24/25 8:03 AM, Brother Bill wrote:
> auto ref string parenthesized(string phrase) {
> string result = '(' ~ phrase ~ ')';
> writeln("&result: ", &result);
> return result; // ← compilation ERROR
> }
First, thank you for reading the book and raising so many issues. Very
m
On 8/23/25 7:58 AM, monkyyy wrote:
>> https://dlang.org/book/templates_more.html#ix_More%20Templates.alias,
>> %20template%20parameter
>
> why is that education material not showing the fundamental pattern of
> `(alias F,T...)(T args)=>F(args)`?
The book was written before that pattern was added
On Sunday, 24 August 2025 at 15:47:28 UTC, Brother Bill wrote:
On Sunday, 24 August 2025 at 15:29:01 UTC, Steven Schveighoffer
wrote:
I don't know what's happening here, but it seems like a bug.
This should not compile (it does for me, despite the comment
above).
It does compile. I didn't
On Sunday, 24 August 2025 at 15:29:01 UTC, Steven Schveighoffer
wrote:
I don't know what's happening here, but it seems like a bug.
This should not compile (it does for me, despite the comment
above).
-Steve
It does compile. I didn't change the comment from earlier code.
The core question
On Sunday, 24 August 2025 at 15:03:12 UTC, Brother Bill wrote:
On page 549 of Programming in D, it appears that D supports
'escaping' local variables to the heap, when returning their
address.
This is similar to Go.
Is this what is actually going on?
Is this 'safe' to do?
```
&result: AC067AF
On page 549 of Programming in D, it appears that D supports
'escaping' local variables to the heap, when returning their
address.
This is similar to Go.
Is this what is actually going on?
Is this 'safe' to do?
```
&result: AC067AF730
&result: AC067AF730
ptrSum : AC067AF7B0 (2 + 3)
sum: (4
On Sunday, 24 August 2025 at 03:13:38 UTC, David T. Oxygen wrote:
The `is_int_or_float()` function has also simplified.
Then I need to use another function to get the type of the
result of `is_int_or_float()`, so I may write another piece of
code like:
```d
import std.stdio;
string inputing="
On Wednesday, 20 August 2025 at 15:33:45 UTC, monkyyy wrote:
once again dconf contains people who talk about compile speed
as if it can be slow
What are they doing? Even my worse compile time abstraction was
O(n^2) or maybe some awful string concatenation of an entire
file; still effectively
On Sunday, 24 August 2025 at 08:25:56 UTC, H. S. Teoh wrote:
On Sun, Aug 24, 2025 at 05:20:06AM +, David T. Oxygen via
Digitalmars-d-learn wrote: [...]
But I still don't know how to use `is` `__traits`.
[...]
Operations involving types, such as type comparisons, are
usually done only insi
On Sunday, 24 August 2025 at 08:35:57 UTC, Per Nordlöw wrote:
Which are the pros and cons of foreach vs static foreach on a
compile time tuple in D in terms of compiler performance and
resource usage? Does static foreach generate more ast
duplications?
--
Yes, it will make the compile-time lo
On Sunday, 24 August 2025 at 08:25:56 UTC, H. S. Teoh wrote:
On Sun, Aug 24, 2025 at 05:20:06AM +, David T. Oxygen via
Digitalmars-d-learn wrote: [...]
But I still don't know how to use `is` `__traits`.
[...]
Operations involving types, such as type comparisons, are
usually done only insi
Which are the pros and cons of foreach vs static foreach on a
compile time tuple in D in terms of compiler performance and
resource usage? Does static foreach generate more ast
duplications?
On Sun, Aug 24, 2025 at 05:20:06AM +, David T. Oxygen via
Digitalmars-d-learn wrote:
[...]
> But I still don't know how to use `is` `__traits`.
[...]
Operations involving types, such as type comparisons, are usually done
only inside an `is`-expression. For example:
```
struct MyType { ... }
24 matches
Mail list logo