User Tools

Site Tools


a_simple_component

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

a_simple_component [2013/06/30 16:36] (current)
barryfp created
Line 1: Line 1:
 +Each Dana component acts as a service that can be used by other components. A component //​provides//​ implementations of one or more abstract objects and //​requires//​ other objects to be implemented by other components. Requirements of a given component C are called dependencies and each one must be satisfied by connecting C to another component that provides an implementation of a compatible object.
  
 +Here is a very simple Dana component:
 +
 +<​code>​
 +component provides App requires io.Output out
 +    {
 +    int App:​main(AppParam *params)
 +        {
 +        out.println("​Hello"​);​
 +        return 0;
 +        }
 +    }
 +</​code>​
 +
 +This component provides an implementation of the **App** object and requires itself to be connected to another component implementing the **io.Output** object. Unlike the majority of dependencies,​ those of type **io.Output** are automatically satisfied by the Dana runtime.
 +
 +From a command prompt we can therefore compile this component:
 +
 +**dnc App.dn**
 +
 +And run it:
 +
 +**dana App.o**
 +
 +And we should see some familiar output.
a_simple_component.txt ยท Last modified: 2013/06/30 16:36 by barryfp