The forked elephant in the room

Walter Bright newshound2 at digitalmars.com
Thu Feb 1 17:49:42 UTC 2024


On 1/31/2024 1:22 PM, Steven Schveighoffer wrote:
> I also think the syntax can be clean without being ambiguous:
> 
> ```d
> // import(C) soundio; // sadly not available because import expressions
> import!C soundio;
> ```


The rationale for not having a special syntax for importing C files is the 
importer should not have to know what language the import comes from. That 
information should not "leak" into the importer's code. The point is seamless 
integration.

Analogously, if one gets from a .di file import:

```
int foo();
```

it should not matter what language foo() is implemented in. The caller should 
not need to know. Having to organize the file names and paths so this works is a 
very small price to pay for this abstraction.

Besides, if you have these files in your folder:

foo.c

foo.d

what is the maintainer looking at the files going to think? Which one is 
incorporated into the code? foo.c? foo.d? both? neither? It's a sloppy practice, 
not some vital thing to support. One can name files as one pleases, organize 
them into sensible folders, etc., all part of doing a good job as a programmer.



More information about the Digitalmars-d mailing list