Inline imports redivivus
qxi
qxi.urt at gmail.com
Mon Jul 26 19:11:32 UTC 2021
On Monday, 26 July 2021 at 12:55:54 UTC, Andrei Alexandrescu
wrote:
> On 7/24/21 3:52 PM, qxi wrote:
>> On Friday, 23 July 2021 at 13:55:34 UTC, Andrei Alexandrescu
>> wrote:
>>> Mathias Lang just told me the bug preventing inline imports
>>> from working has been fixed, so I reopened this:
>>>
>>> https://github.com/dlang/druntime/pull/1756
>>>
>>> I think it's a very useful facility, more clearly so for
>>> large projects, and deserves a fair shake of the stick.
>>>
>>> If it works well in practice, a future language proposal
>>> could take `_import!"std.datetime".SysTime` to the simpler
>>> and better `import(std.datetime).SysTime`. Using it as a
>>> library facility seems like a good step.
>>
>> import[std.datetime].SysTime
>> import{std.datetime}.SysTime
>> import std.datetime..SysTime
>> import std.datetime::SysTime
>> std.datetime::SysTime
>
> import:std.datetime.SysTime
Problem with 'import:std.datetime.SysTime' is that we cant tell
which identifier is imported symbol (unless we assume that the
last identifier is an imported symbol),
for example 'import:A.B.C' we dont know we import symbol 'B' from
module 'A' or symbol 'C' from module 'A.B', with may both exists.
Examples that dont work:
import:Module.Struct.StaticFunction(arguments)
import:Module.AliasToTplInst.SomeType
I know it is possible to write
'(import:Module.Struct).StaticFunction(arguments)' but that dont
look right (at least for me), and in my examples using brackets
or tokens is to easier distinguish module name from imported
symbol (in all cases).
More information about the Digitalmars-d
mailing list