No main() Error

Atila Neves atila.neves at gmail.com
Wed Feb 12 09:32:18 UTC 2025


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.


More information about the dip.ideas mailing list