-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathModules.t2t
More file actions
54 lines (38 loc) · 1.87 KB
/
Modules.t2t
File metadata and controls
54 lines (38 loc) · 1.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
Modules
%!includeconf: config.t2t
== Introduction ==
In Pool all code is organized into a series of modules. This allows to keep
code organized (there is nothing like scrolling through a 20 000 line file
trying to find out where you defined ``foo()``). Pool has a strict module
system to ensure that people can find what they want even if they didn't right
it. This also allows automated builds with minimal buildscripts and powerful
tools that work out-of-the-box.
== Files ==
Every file is a module. The file must have a ``module`` statement that matches
it's location on the filesystem. For example if there was a statement
``module foo::bar`` it should be in a file named ``bar.pool`` inside of a
directory called ``foo``.
== Visibility ==
Visibility is a very important aspect of clean code. You need to let people
know what they should be calling and what is an implementation detail. In Pool
everything is private by default. This is to ensure that you don't expose too
much. To make something private simpaly prefix a statement that creates a new
name with ``public`` and it will be exported to any module that ``import``s
the current one.
Visibility is handled at the module level. This means that anything inside of a
module can see anything else inside of it.
```
var i = 10; // Private
public var j = 20; // Public
public class { Foo;
var _value = 5; // Private variable.
public {property (int) value (); return _value }; // Public setter.
{property (int) value (v:int); return _value = v }; // Private getter.
public {()double(); value *= 2 } // Public.
}
public { ()triple(Foo *f); f.value *= 3; } // Legal, same module.
```
=== Inheritance and Visibility ===
There is a third form of visibility for classes, `protected`. If a class member
is marked as ``protected` as opposed to `public` only classes which derive from
it can access that information.