Leave Comments, Critiques, and Suggestions Here?
next>> Chapter 4 - Building and Compiling [Table of Contents] Chapter 2 - Tango Installation <<prev
Tango: some basic steps
After a successfull installation, the first thing to do is trying to get our first basic steps compiled and run.
Lets first say hello to our dancing partner, the computer:
import tango.io.Console; void main() { Cout ("Hello, sweetheart \u263a").newline; }
This illustrates bare console output, with no fancy formatting. One could use the Stdout module instead, which supports quite sophisticated formatting options.
Console I/O in Tango is UTF-8 across both Linux and Win32, and conversion between various unicode representations is handled as necessary by higher level constructs such as Stdout and Format.
Now we also expect our computer to tell us something. In this case, we use Cin.get() to retrieve a string from console:
import tango.io.Console; void main() { auto s = Cin.get(); Cout ("Hello, ")(s).newline; }
To compile this program using bud, the command would look something like this:
bud mytestprogram.d # may need to specify the -op switch on Linux
next>> Chapter 4 - Building and Compiling [Table of Contents] Chapter 2 - Tango Installation <<prev