Bug 20172 – using functions with full path and without preliminary import

Status
RESOLVED
Resolution
WONTFIX
Severity
enhancement
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2019-08-27T13:02:54Z
Last change time
2019-08-30T09:13:29Z
Assigned to
No Owner
Creator
a11e99z

Comments

Comment #0 by black80 — 2019-08-27T13:02:54Z
sometimes imported functions used in simple context suggestion: add possibility to use imported function in-situ with full path struct S { void freeItem( void* pelem ) { // now: u should import before call //import core.stdc.stdlib : free; // no needed // suggestion: just call core.stdc.stdlib.free( pelem ); } } full path modules.func( .. ) tells exactly function that needed with less LOC, key press and without blurring eyes by 2 separate items: import and invoke
Comment #1 by simen.kjaras — 2019-08-28T08:26:54Z
Is foo.bar.baz referring to the free function baz in the module foo.bar, or the member baz in the type bar in the module foo? In addition to this ambiguity, this effectively turns every typo into an expensive file system lookup.
Comment #2 by black80 — 2019-08-30T09:13:29Z
(In reply to Simen Kjaeraas from comment #1) > Is foo.bar.baz referring to the free function baz in the module foo.bar, or > the member baz in the type bar in the module foo? In addition to this > ambiguity, this effectively turns every typo into an expensive file system > lookup. in any case u(D gods) can extend syntax core.stdc.stdlib:free( pelem ) foo.bar:baz colon":" that split module path from type.method path meaning left be same as now but shorter in 1LOC