| Paste number 48751: | class and namespace modules idea |
| Pasted by: | |Agent |
| 1 year, 1 week ago | |
| #dylan | Context in IRC logs | |
| Paste contents: |
| namespace alpha { class X { int i; void print(); void print(int a); } class Y { void print(); } } namespace beta { class X { void print(); } } --------------- define module alpha use alpha::X, prefix: "X::", export <X> use alpha::Y, prefix: "Y::", export <Y> export print; // The keyword-only generic, dispatches to X or Y export i, i-setter; // Only dispatches to X end define module beta use beta::X, prefix: "X::", export <X> export print; // Dispatches to X end define module alpha::X export <X>, i, i-setter, print end define module alpha::Y export <Y>, print end define module beta::X export <X>, print end |
Annotations for this paste:
| Annotation number 1: | usage example |
| Pasted by: | |Agent |
| 1 year, 1 week ago | |
| Context in IRC logs | |
| Paste contents: |
| If you are only using namespace alpha, then you can just use class <X>, but if you use both, you'll have to prefix and say alpha::<X> or beta::<X>. If you are only using beta::X, then you can use print() without a disambig. prefix. |
| Annotation number 2: | Add'l note |
| Pasted by: | |Agent |
| 1 year, 1 week ago | |
| Context in IRC logs | |
| Paste contents: |
| In the alpha module, i and i-setter would be aliased to X::i and X::i-setter, but print would have a method in the alpha module itself to dispatch to X::print or Y::print. |