Inline imports redivivus

Daniel N no at public.email
Sat Mar 12 19:33:16 UTC 2022


On Saturday, 12 March 2022 at 19:13:33 UTC, Zach Tollen wrote:
> On Friday, 11 March 2022 at 13:01:43 UTC, Ali Çehreli wrote:
>> Perhaps a second meaning for ..? And is : really necessary?
>
> The character `|` might work too. It looks better if we close 
> it with the same character.
> ```d
>    x = |std.datetime|SysTime;
> ```
> I actually like this one a lot. There is some potential lexical 
> ambiguity with `|` and `||` as binary operators. However, those 
> operators are typically separated with whitespace in ordinary 
> code, so I don't think it will ever be a problem. (The second 
> `|` in `|std.datetime|SysTime` can be parsed as a part of 
> `|modname|symbol`, so apart from typos, there's no syntactical 
> problem.)
>
> The worst you would suffer would be the visual confusion of 
> something like this:
> ```d
> if (|std.something|condition(sdfd) || 
> |some.other.inlinemodule|Test
>       || |othermod.imp|mycondition) {
>    myFlags = |std.something|Flagset | |std.otherthing|Flags;
> }
> ```
> This would be the extreme case I think. Syntax highlighting 
> could help.
>
> I think this is better than `$std.datetime:SysTime`.

Out of your new alternatives, I like this one the best.
```d
x = :std.datetime:SysTime;
```

1) It is symmetric same as ||
2) : is already used in import x:y
3) : is not used in expressions unlike | which is quite common.
4) We can keep $ for some future codegen features.




More information about the Digitalmars-d mailing list