Re: why is "hello".writeln considered bad?

2020-11-19 Thread Mike Parker via Digitalmars-d-learn
On Friday, 20 November 2020 at 07:39:10 UTC, norm wrote: I was reading some posts and this was presented as a snippet of code and was immediately flagged as bad practice. Eh, I wouldn't quite put it that way. If we're thinking of the same thread, one person said he thought it was a bad

why is "hello".writeln considered bad?

2020-11-19 Thread norm via Digitalmars-d-learn
I was reading some posts and this was presented as a snippet of code and was immediately flagged as bad practice. I get some people don't like it but occasionally I prefer this syntax. It feels more declarative and fluent in style. Is there a good technical reason why it is bad practice, e.g.

Re: DMD -i option, simple question...

2020-11-19 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 20 November 2020 at 03:06:37 UTC, WhatMeWorry wrote: The "..when this option is enabled..." is exactly the behavior I want, but how is it enabled? Is there an "all inclusive pattern" that I'm missing. dmd -i yourfile.d that's the default it is describing when you don't specify

DMD -i option, simple question...

2020-11-19 Thread WhatMeWorry via Digitalmars-d-learn
The DMD forum mentions internal design. This is more of a beginner usage question. - from Compiler Switches - -I=directory Look for imports also in directory -i[=pattern ] Enables "include imports" mode, where the compiler will

Re: Calling function within class.

2020-11-19 Thread frame via Digitalmars-d-learn
On Thursday, 19 November 2020 at 19:51:24 UTC, Vino wrote: the moment we enable parallelism, it is throwing an error on the SQL part (Fetch the username/ password from the table for each account), as it could not execute the SQL query in parallel for different account. I see no reason for a

Re: Calling function within class.

2020-11-19 Thread Vino via Digitalmars-d-learn
On Wednesday, 18 November 2020 at 21:33:58 UTC, Ali Çehreli wrote: On 11/18/20 7:01 AM, Vino wrote: >Request your help on how to call a function(listFile) from another > function(getFilelist) within the same class(GetDirlist), below is an > example code. That code looks unnecessarily

Re: betterC question

2020-11-19 Thread Dibyendu Majumdar via Digitalmars-d-learn
On Thursday, 19 November 2020 at 14:34:38 UTC, Adam D. Ruppe wrote: On Thursday, 19 November 2020 at 00:20:50 UTC, Dibyendu Majumdar wrote: Okay thanks. Bad idea IMO. That's kinda how I see C taking the address of various things implicitly. To be honest it seems irrelevant what C does.

Re: implementing default opCmp

2020-11-19 Thread Ali Çehreli via Digitalmars-d-learn
On 11/19/20 6:12 AM, Steven Schveighoffer wrote: On 11/18/20 6:06 PM, ag0aep6g wrote: int opCmp(S other) { import std.typecons: tuple; return tuple(this.tupleof).opCmp(tuple(other.tupleof)); } Ah, excellent solution! I hadn't thought of that. -Steve

Re: Function Pointer Not Working

2020-11-19 Thread Marcone via Digitalmars-d-learn
I will wait with this code. WaitForSingleObject(threading, INFINITE);

Re: betterC question

2020-11-19 Thread Jack via Digitalmars-d-learn
On Thursday, 19 November 2020 at 14:34:38 UTC, Adam D. Ruppe wrote: On Thursday, 19 November 2020 at 00:20:50 UTC, Dibyendu Majumdar wrote: Okay thanks. Bad idea IMO. That's kinda how I see C taking the address of various things implicitly. good example

Re: Function Pointer Not Working

2020-11-19 Thread Marcone via Digitalmars-d-learn
On Thursday, 19 November 2020 at 15:51:09 UTC, Kagamin wrote: The delegate is stored on the stack of the calling thread, the created thread loads it from there, but the calling thread doesn't wait for that and clobbers the stack right away. If you were lucky your code would crash. The thread

Re: Function Pointer Not Working

2020-11-19 Thread Kagamin via Digitalmars-d-learn
The delegate is stored on the stack of the calling thread, the created thread loads it from there, but the calling thread doesn't wait for that and clobbers the stack right away. If you were lucky your code would crash.

Re: betterC question

2020-11-19 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 19 November 2020 at 00:20:50 UTC, Dibyendu Majumdar wrote: Okay thanks. Bad idea IMO. That's kinda how I see C taking the address of various things implicitly.

Re: implementing default opCmp

2020-11-19 Thread Steven Schveighoffer via Digitalmars-d-learn
On 11/18/20 6:06 PM, ag0aep6g wrote: On Wednesday, 18 November 2020 at 22:29:17 UTC, Steven Schveighoffer wrote: How do I do something really simple for opCmp? I tried this it didn't work: return this == other ? 0 :     this.tupleof < other.tupleof ? -1 : 1; std.typecons.Tuple has opCmp. So

Re: implementing default opCmp

2020-11-19 Thread Steven Schveighoffer via Digitalmars-d-learn
On 11/18/20 6:02 PM, Paul Backus wrote: On Wednesday, 18 November 2020 at 22:29:17 UTC, Steven Schveighoffer wrote: I have a struct like this: struct S {    int x;    int y; } and I want a default comparison. The problem is, that comparison doesn't have a default, and requires I implement

Re: Function Pointer Not Working

2020-11-19 Thread Marcone via Digitalmars-d-learn
Solved replacing this line: CreateThread(null, 0, &_fun, , 0, null); to this code: task!({CreateThread(null, 0, &_fun, , 0, null);}).executeInNewThread();

Re: betterC question

2020-11-19 Thread Basile B. via Digitalmars-d-learn
On Thursday, 19 November 2020 at 00:07:12 UTC, Dibyendu Majumdar wrote: I have simple test program: import core.stdc.stdio : printf; void test() { int* a; printf("a == null %d\n", a == null); } int function() fp = test; extern (C) void main() { fp(); } Why do I get:

Re: betterC question

2020-11-19 Thread Dibyendu Majumdar via Digitalmars-d-learn
On Thursday, 19 November 2020 at 09:23:25 UTC, Jacob Carlborg wrote: Yes, calling `writeln` like that is a bad idea. That was a bad example. But the actual reason is, this is how D implements properties [1]. Any function that doesn't take an argument can be called without parentheses. Any

Re: betterC question

2020-11-19 Thread Dibyendu Majumdar via Digitalmars-d-learn
On Thursday, 19 November 2020 at 01:42:16 UTC, Mike Parker wrote: On Thursday, 19 November 2020 at 00:20:50 UTC, Dibyendu Majumdar wrote: On Thursday, 19 November 2020 at 00:18:54 UTC, rikki cattermole wrote: You don't need the brackets to call a function (and with a little help from

Re: betterC question

2020-11-19 Thread Jacob Carlborg via Digitalmars-d-learn
On Thursday, 19 November 2020 at 00:20:50 UTC, Dibyendu Majumdar wrote: On Thursday, 19 November 2020 at 00:18:54 UTC, rikki cattermole You don't need the brackets to call a function (and with a little help from UFCS): void main() { import std.stdio;

Re: Calling function within class.

2020-11-19 Thread frame via Digitalmars-d-learn
On Wednesday, 18 November 2020 at 19:25:06 UTC, Vino wrote: The above code is a sample code, but the logic is same, correct me if my understanding is wrong, in the above code "obj" is a an object for the class GetDirlist, so we are accessing the class member using "obj.listFile(st)" , so

Re: Can't pass [] to extern function object method

2020-11-19 Thread frame via Digitalmars-d-learn
On Thursday, 19 November 2020 at 07:46:20 UTC, Bastiaan Veelo wrote: On Wednesday, 18 November 2020 at 10:50:12 UTC, frame wrote: I found the "bug". It was caused by a debug {} statement within a struct method. I assume that the debug symbol is just incompatible called from the DLL context.