User Tools

Site Tools


standard-library

Table of Contents

Dana's standard library, or central source tree, contains a wide range of generally useful components to support data manipulation, networking, and interaction with the operating system to perform actions such as reading the current date and time.

You can use this functionality be declaring that your component requires a given interface from the standard library, such as requires net.TCPSocket.

You can browse the functionality of the standard library by examining the “resources” folder of Dana; this contains all of the interfaces supported by the standard library and each interface is commented to describe its general purpose.

Here we describe the main folders of the standard library and what they are for.

composition

This folder contains interfaces to help control the composition of a piece of software. The main interface here is the loader, allowing you to load components into memory.

data

This folder contains interfaces to manipulate integers and strings, and contains a sub-folder adt for abstract data types to create lists and hash maps of data.

The StringUtil interface would for example be used like this:

component provides App requires data.StringUtil stringUtil{
   int App:main(AppParam params[])
      {
      String s = stingUtil.subString(params[0].string, 1, 5)
 
      return 0
      }
   }

This gets a sub string (characters 1-6) of the first command line parameter.

data.adt

This folder contains abstract data types like lists, queues and hash tables. As an example, you can create and iterate over a list as follows:

data Person{
   copy char name[]
   }
 
component provides App requires data.adt.List, io.Output out{
   int App:main(AppParam params[])
      {
      List l = new List()
      l.add(new Person("Sam"))
      l.add(new Person("Alex"))
      l.add(new Person("Joe"))
 
      for (Person p = l.getFirst(); p != null; p = l.getNext())
         {
         out.println(p.name)
         }
 
      return 0
      }
   }

io

This folder contains interfaces for input and output operations, including terminal / command-line operations (io.Input and io.Output) and file / file system operations.

As an example, you can write to a file as follows:

component provides App requires io.File {
 
   int App:main(AppParam params[])
      {
      File fd = new File("test.txt", File.FILE_ACCESS_WRITE)
      fd.write("some text")
      fd.close()
 
      return 0
      }
 
}

net

This folder contains interfaces to do computer networking, including both TCP and UDP. See the components/examples folder for various example programs that use networking support.

time

This folder contains interfaces to get the current system date and time and also to pause a thread for a given time interval (using the Timer interface).

ui

This folder contains interfaces to create graphical user interfaces; this functionality currently works only on Microsoft Windows platforms.

standard-library.txt · Last modified: 2015/12/17 04:12 by barryfp

Page Tools