summaryrefslogtreecommitdiff
path: root/sources
diff options
context:
space:
mode:
authorMatthias Zenger <mzenger@gmail.com>2004-01-12 15:44:30 +0000
committerMatthias Zenger <mzenger@gmail.com>2004-01-12 15:44:30 +0000
commitbf1d9d46d08f2c835d342142b31a1ce32550d31c (patch)
tree749f155da1ba10ebbb6df72e5204f3f903ee141c /sources
parent33d36a45ebba56b12aabd31c6ca1b49784485d43 (diff)
downloadscala-bf1d9d46d08f2c835d342142b31a1ce32550d31c.tar.gz
scala-bf1d9d46d08f2c835d342142b31a1ce32550d31c.tar.bz2
scala-bf1d9d46d08f2c835d342142b31a1ce32550d31c.zip
Formerly known as class Executable.
Diffstat (limited to 'sources')
-rw-r--r--sources/scala/Application.scala51
1 files changed, 51 insertions, 0 deletions
diff --git a/sources/scala/Application.scala b/sources/scala/Application.scala
new file mode 100644
index 0000000000..bb289ed79d
--- /dev/null
+++ b/sources/scala/Application.scala
@@ -0,0 +1,51 @@
+/* __ *\
+** ________ ___ / / ___ Scala API **
+** / __/ __// _ | / / / _ | (c) 2002, LAMP/EPFL **
+** __\ \/ /__/ __ |/ /__/ __ | **
+** /____/\___/_/ |_/____/_/ | | **
+** |/ **
+** $Id$
+\* */
+
+package scala;
+
+
+/** The <code>Application</code> class can be used to quickly turn objects
+ * into executable programs. Here is an example:
+ * <pre>
+ * object Main with Application {
+ * Console.println("Hello World!");
+ * }
+ * </pre>
+ * Here, object <code>Main</code> inherits the <code>main</code> method
+ * of <code>Application</code>. The body of the <code>Main</code> object
+ * defines the main program. This technique does not work if the main
+ * program depends on command-line arguments (which are not accessible
+ * with the technique presented here).
+ *
+ * It is possible to time the execution of objects that inherit from
+ * class <code>Application</code> by setting the global scala.time property.
+ * Here is an example for benchmarking object <code>Main</code>:
+ * <pre>
+ * java -Dscala.time Main
+ * </pre>
+ *
+ * @author Matthias Zenger
+ * @version 1.0, 10/09/03
+ */
+
+class Application {
+
+ /** The time when execution of this program started.
+ */
+ val executionStart: Long = java.lang.System.currentTimeMillis();
+
+ /** The default main method.
+ */
+ def main(args: Array[String]) = {
+ if (java.lang.System.getProperty("scala.time") != null)
+ java.lang.System.out.println("[total " +
+ (java.lang.System.currentTimeMillis()
+ - executionStart) + "ms]");
+ }
+}