February 05
On Wednesday, 5 February 2025 at 05:34:09 UTC, Richard (Rikki) Andrew Cattermole wrote:
>
> What you are asking for is a nice customized error message for D.
>
> Which as far as I'm aware is not supported by any linker.

So, what you're saying is that DMD doesn't have its own linker? That never occurred to me.

On the other hand, if D uses a linker previously built for other compilers (C or C++, I assume) I'm surprised that this already-existing linker doesn't have such an error message.

On the other-other hand, if linkers are used for building both executables and libraries, it does make sense in a way. I mean, otherwise the linker developer would have to allow for a command line switch telling the linker the specific output of the build: library, or executable.

But this now sounds like a discussion for another venue. Not sure which, so instead, I'm going to write up a little note to post on my monitor bezel, something like:

Does your code have a main() function?

I guess that will have to do. Thanks for the discussion, guys. It's been fun.
February 05
On 05/02/2025 9:48 PM, Ron Tarrant wrote:
> On Wednesday, 5 February 2025 at 05:34:09 UTC, Richard (Rikki) Andrew Cattermole wrote:
>>
>> What you are asking for is a nice customized error message for D.
>>
>> Which as far as I'm aware is not supported by any linker.
> 
> So, what you're saying is that DMD doesn't have its own linker? That never occurred to me.

Not anymore. We did have Optlink for Windows 32bit, but that was written in the 80's for C/C++.

> On the other hand, if D uses a linker previously built for other compilers (C or C++, I assume) I'm surprised that this already-existing linker doesn't have such an error message.

It does, when you produce an executable.

All of them have had it since their inception (more or less).

> On the other-other hand, if linkers are used for building both executables and libraries, it does make sense in a way. I mean, otherwise the linker developer would have to allow for a command line switch telling the linker the specific output of the build: library, or executable.

You specify if you want a shared library or executable.

Some will also act as an archiver for static libraries.

February 12

On Tuesday, 4 February 2025 at 22:14:40 UTC, Paul Backus wrote:

>

On Sunday, 2 February 2025 at 10:06:29 UTC, Ron Tarrant wrote:

>

Most of the code I write these days is in Python. I turned to D for a small project this morning and while doing some preliminary exploration into file handling, I got a "Declaration expected" error while trying to write a foreach() loop.

It sounds like what you are really asking for here is a better error message when the compiler encounters a statement outside of a function.

E.g., if the compiler sees a control-flow keyword like foreach or if at the top-level scope of a module, instead of saying "declaration expected", it could say something like "foreach statement is not allowed outside of a function."

I agree that this would be a worthwhile improvement.

This makes sense to me.

February 12
I'm not sure what code you're writing. Can you post an example, please?
February 12
On Wednesday, 12 February 2025 at 18:57:28 UTC, Walter Bright wrote:
> I'm not sure what code you're writing. Can you post an example, please?

```d
import std;
"hello world".writeln;
```
February 12
On 2/4/2025 1:25 AM, Richard (Rikki) Andrew Cattermole wrote:
> It looks like it can work without semantic analysis having been done too.

Linkage requires semantic analysis. isNested and isMember are not determined by the parser, either.
February 13
On 13/02/2025 10:13 AM, Walter Bright wrote:
> On 2/4/2025 1:25 AM, Richard (Rikki) Andrew Cattermole wrote:
>> It looks like it can work without semantic analysis having been done too.
> 
> Linkage requires semantic analysis. isNested and isMember are not determined by the parser, either.

Yeah I learned that two days ago. That it was much later than I thought it would be.

Regardless it doesn't change my responses here regarding main function detection. It doesn't nor should it be special cased like originally requested as that is the job of the linker.

February 13
thank you
February 15

On Wednesday, 12 February 2025 at 18:57:28 UTC, Walter Bright wrote:

>

I'm not sure what code you're writing. Can you post an example, please?

Hi, Walter. Thanks for replying.

Although the errors may not be the same (I don't remember what errors I got, frankly. I've put the entire experience out of my mind since it was a tad embarrassing and I've long since tossed the code.) it was something like this:

module copy_file_std;

import std.stdio;
import std.file;
import std.exception;

// this is a new comment
void copyFile(string sourcePath, string destinationPath)
{
	try
	{
		// Option 1: Using std.file.copy (Simplest for basic copies)
		copy(sourcePath, destinationPath);
		writeln("File copied successfully using std.file.copy.");
	}
	catch (Exception e)
	{
		stderr.writeln("Error copying file: ", e.msg);
	}
}

string source = "./copy_file_std.d";
string destination = "./subdir/copy_file_std.d";

if (!exists(source))
{
	stderr.writeln("Source file does not exist!");
	return;
}

copyFile(source, destination);

I neglected to wrap the last statement in void main() {} which, naturally, fixed it.

1 2
Next ›   Last »