Fully agreed!
Any volunteer? :-)
-- Gaby
From: Matt Austern [mailto:aus...@google.com]
Sent: Sunday, May 18, 2014 6:30 PM
To: c++st...@accu.org
Subject: [c++std-ext-14848] Re: [modules] Draft of a module design
This suggests that a one-pager requirements document, i.e. listing the problems that a module design ought to solve, would be useful. It would be especially useful if it turned out that different people have different ideas of what problems matter.
Actually, I prefer a fourth option:
(4)
module X1;
import X2; // import for use in defining the exported symbols
export { set_of_symbols... } // export symbols
export { import X3; } // illegal, reexport not permitted
module x1{
export {
import x2;
class A;
class B;
}
};
using module x1::A;//pick just A and it's dependencies skips everything else
> May be a 5th option: specify which symbols we want to be imported, and
> transitively their dependencies.
>
> module x1{
> export {
> import x2;
> class A;
> class B;
> }
> };
I don't think I understand the proposal. It looks like A is defined in x1.
What about the symbols in x2?
class A : public X {
foo(std::map<int, int>& m){...}
public:
A(const std::string& s) {...}
A(const std::vector<std::string>& v) {}
};
What about ADL? Should it find entities that are exported but not explicitly named in the import? With CRTP, many of these entities aren’t reachable from usual name lookup rules. This is slippery slope...
--
What about ADL? Should it find entities that are exported but not explicitly named in the import? With CRTP, many of these entities aren’t reachable from usual name lookup rules. This is slippery slope...
On 21 May 2014 16:32, Gabriel Dos Reis <g...@microsoft.com> wrote:
What about ADL? Should it find entities that are exported but not explicitly named in the import? With CRTP, many of these entities aren’t reachable from usual name lookup rules. This is slippery slope...
I've already had to deal with ADL in Clang's prototype implementation. Our rules (which I think are probably the appropriate ones) work as follows:
* Form a set of surrounding instantiations by following the rules in 14.6.4.1 [temp.point]. This set is the sequence of instantiations that are followed from a specialization to find its point of instantiation.* For a name to be visible to argument-dependent name lookup, it must be visible (within an associated namespace, per the non-modules ADL rules) within a module containing a member of the set of surrounding instantiations, or visible from the translation unit.
Essentially, the idea is to capture the notion that an instantiation can depend on names introduced anywhere in the minimal path of instantiations that leads to that instantiation being performed, but cannot depend on names that are declared anywhere else.
More naive rules (such as only looking in the module containing the template definition and in the translation unit) are non-composable and fail very quickly in real-world code.
What about ADL? Should it find entities that are exported but not explicitly named in the import?
With CRTP, many of these entities aren’t reachable from usual name lookup rules.
module x1 {
export {
class T;
class B;
void foo(X<T>);
}
template<class _Tp> class X {};
class T : public X<T> {};
void foo(X<T>) {}.
}
module x2 {
import x1::T; // here we get T, X<T> and foo(X<T>)
}
Em quarta-feira, 21 de maio de 2014 20h32min20s UTC-3, Gabriel Dos Reis escreveu:What about ADL? Should it find entities that are exported but not explicitly named in the import?
Yes... I think...It´s better than import all exported symbols, isn´t ?
With CRTP, many of these entities aren’t reachable from usual name lookup rules.
Yes, if you define
x1.cpp
module x1 {
export {
class T;
class B;
void foo(X<T>);
}
template<class _Tp> class X {};
class T : public X<T> {};
void foo(X<T>) {}.
}
x2.cpp
module x2 {
import x1::T; // here we get T, X<T> and foo(X<T>)
}
At least we avoid to import B.
Thanks
module x0{
export {
class W { int w_mem; } class Z { int z_mem; }
}
}
module x1 {
export {
import x0;
template<typename _Tp> class X { int m1; };
class T : public X<T> { int m2; }
class B { int m1; }
void foo(const T& t) {}
};
void foo2(W w) {}
void foo3(Z z) {}
}
import x1;
int main() {
T t;
.
.
.
return 0;
}
But in main.cpp we use only T, no direct reference to B, or X, or W or Z or foo nor X<T>. Right ?
But in main.cpp we use only T, no direct reference to B, or X, or W or Z or foo nor X<T>. Right ?
Correct.
I suspect only practical experience and hard data would tell us how much of a problem it is in practice - in a module world, not head files world. Clearly, the alternative does not make available only things that are mentioned.