This is an old revision of the document!
Automated linking is the default mode in which Dana operates. Each dependency of each component is automatically linked to the default component implementing that dependency at program execution time. It's good for rapid prototyping and for writing quick little programs here and there. The same programs can be used, without modification, with Dana's other mechanisms for inter-component connection.
Almost all of the examples that come with Dana use dynamic linking by default. If you compile examples/SysTest.dn and os/SystemInfo.dn using the Dana compiler, then use the command
You'll see that the program runs as expected, without having to explicitly specify that the component SysTest.dn should in particular use the component os/SystemInfo.dn to satisfy its dependency on the os.SystemInfo interface.
As you might guess, this automated linking is primarily based upon simple name equivalence. If there's a component with the same package path, with the same file name as the interface's type name, Dana will attempt to use that component to satisfy the dependency.
In some cases however this simple name equivalence isn't enough and we need more information. This happens when a component's source file name has no direct relationship to the interfaces that it implements, such as the TCP component which implements both TCPSocket and TCPServerSocket.
In these cases Dana uses “manifest” files to assist with the automated linking system. In some folders, like components/net/, you'll therefore notice a file called
This file contains JSON which specifies how to map interface types to component implementations in this package. You can open the file in a text editor to see the format of this mapping. You can also add more mappings as you develop your own components.
When searching for components to satisfy dependencies, Dana uses the following precedence rules:
1. Check for a .manifest file in the folder of the component that declares the dependency; if found, see if that manifest file specifies a default component map this dependency to.
2. Check if there is a component in the folder of the component that declares the dependency, whose package path and name matches the dependency's interface name.
3. Check in Dana's central source tree (i.e. components/) for a .manifest file in the corresponding package path; if found, see if that manifest file specifies a default component map this dependency to.
4. Check in Dana's central source tree for a component in the matching package path of the dependency, whose name matches the dependency's interface name.
If all of these search steps fail to find a candidate component, automated linking will not succeed.
Note that the automated linking procedure does not attempt to compile components, it only searches for components that are already compiled.