Update suitable examples and tests to use blank mode
[shapes.git] / examples / doc / namespace-aliases.blank
blob1ed474905b15822df30cecea590c5a0b96c7588f
1 /** This file is part of Shapes.
2  **
3  ** Shapes is free software: you can redistribute it and/or modify
4  ** it under the terms of the GNU General Public License as published by
5  ** the Free Software Foundation, either version 3 of the License, or
6  ** any later version.
7  **
8  ** Shapes is distributed in the hope that it will be useful,
9  ** but WITHOUT ANY WARRANTY; without even the implied warranty of
10  ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11  ** GNU General Public License for more details.
12  **
13  ** You should have received a copy of the GNU General Public License
14  ** along with Shapes.  If not, see <http://www.gnu.org/licenses/>.
15  **
16  ** Copyright 2015 Henrik Tidefelt
17  **/
19 ##lookin ..Shapes
21 /** Populate a namespace hierarchy.
22  **/
23 ##push W
24 ##push X
25 ##push Y
26 ##push Z
27 a: 1
28 ##pop Z
29 ##pop Y
30 ##pop X
31 ##pop W
34 /** Alias with absolute expansion, placed in the global namespace
35  **/
36 ##alias K = ..W..X..Y
38 /** The alias can be accessed using a relative identifier.
39  **/
41   res: [Debug..locate (resolved_identifier_string K..Z..a)]
42   IO..•stdout << `Resolving ´ << [Debug..sourceof res] << ` within ´ << (resolved_identifier_string @@) << `: ´ << res << "{n}
46 ##push W
48 /** Alias with relative expansion
49  ** The expansion is resolved relative to the current namespace (here ..W)
50  **/
51 ##alias L = X..Y
53 /** Expand the alias from a nested namespace.
54  **/
55 ##push R
57   res: [Debug..locate (resolved_identifier_string L..Z..a)]
58   IO..•stdout << `Resolving ´ << [Debug..sourceof res] << ` within ´ << (resolved_identifier_string @@) << `: ´ << res << "{n}
60 ##pop R
62 ##pop W
65 ##push W
67 /** Expand the alias from the same namespace opened again.
68  **/
70   res: [Debug..locate (resolved_identifier_string L..Z..a)]
71   IO..•stdout << `Resolving ´ << [Debug..sourceof res] << ` within ´ << (resolved_identifier_string @@) << `: ´ << res << "{n}
74 ##pop W
77 /** Namespace aliases are only followed for the first namespace name in a namespace path.
78  ** This is to allow an extension to use aliases for its own convenience, without the risk that
79  ** users of the extension create dependencies to these aliases.
80  **
81  ** This wouldn't work:
82  **/
83 |**{
84 |**  res: [Debug..locate (resolved_identifier_string W..L..Z..a)]
85 |**  IO..•stdout << `Resolving ´ << [Debug..sourceof res] << ` within ´ << (resolved_identifier_string @@) << `: ´ << res << "{n}
86 |**}