import(__FILE_LITERAL__)

monkyyy crazymonkyyy at gmail.com
Mon Sep 9 18:18:31 UTC 2024


Import Expressions are limited and had to use in abstractions 
because they require the user to pass `-J=.`, which given the 
average d user uses dub; suggesting such a thing requires a 3 
step process.

> Note that by default an import expression will not compile 
> unless one or more paths are passed via the -J switch. This 
> tells the compiler where it should look for the files to 
> import. This is a security feature.

My opinion on the subject may violate the dip forum guidelines.

---

I suggest that its safe to read the file the user is compiling 
during compilation. I suggest that new special token that 
generates ... something that an import expression can take 
without a `-J=.`.

```d
import foo;//lolz
import std;
enum string=import(__FILE_LITERAL__).split('/n').front;// "import 
foo;//lolz"
```

By separating it into two step process you could use the special 
token magic
`void foo(alias file=__FILE_LITERAL__,int line=__LINE__)(){`


More information about the dip.ideas mailing list