2015-11-09 08:01:19 -08:00
<!DOCTYPE html>
< html >
< head >
< meta http-equiv = "Content-type" content = "text/html;charset=UTF-8" / >
< title > System Class – Wren< / title >
< link rel = "stylesheet" type = "text/css" href = "../../style.css" / >
< link href = '//fonts.googleapis.com/css?family=Source+Sans+Pro:400,700,400italic,700italic|Source+Code+Pro:400|Lato:400|Sanchez:400italic,400' rel = 'stylesheet' type = 'text/css' >
<!-- Tell mobile browsers we're optimized for them and they don't need to crop
the viewport. -->
< meta name = "viewport" content = "width=device-width, initial-scale=1, maximum-scale=1" / >
< / head >
< body id = "top" class = "module" >
< header >
< div class = "page" >
< div class = "main-column" >
< h1 > < a href = "../../" > wren< / a > < / h1 >
< h2 > a classy little scripting language< / h2 >
< / div >
< / div >
< / header >
< div class = "page" >
< nav class = "big" >
< ul >
< li > < a href = "../" > Modules< / a > < / li >
< li > < a href = "./" > core< / a > < / li >
< / ul >
< section >
< h2 > core classes< / h2 >
< ul >
< li > < a href = "bool.html" > Bool< / a > < / li >
< li > < a href = "class.html" > Class< / a > < / li >
< li > < a href = "fiber.html" > Fiber< / a > < / li >
< li > < a href = "fn.html" > Fn< / a > < / li >
< li > < a href = "list.html" > List< / a > < / li >
< li > < a href = "map.html" > Map< / a > < / li >
< li > < a href = "null.html" > Null< / a > < / li >
< li > < a href = "num.html" > Num< / a > < / li >
< li > < a href = "object.html" > Object< / a > < / li >
< li > < a href = "range.html" > Range< / a > < / li >
< li > < a href = "sequence.html" > Sequence< / a > < / li >
< li > < a href = "string.html" > String< / a > < / li >
< li > < a href = "system.html" > System< / a > < / li >
< / ul >
< / section >
< / nav >
< nav class = "small" >
< table >
< tr >
< td > < a href = "../" > Modules< / a > < / td >
< td > < a href = "./" > core< / a > < / td >
< / tr >
< tr >
< td colspan = "2" > < h2 > core classes< / h2 > < / td >
< / tr >
< tr >
< td >
< ul >
< li > < a href = "bool.html" > Bool< / a > < / li >
< li > < a href = "class.html" > Class< / a > < / li >
< li > < a href = "fiber.html" > Fiber< / a > < / li >
< li > < a href = "fn.html" > Fn< / a > < / li >
< li > < a href = "list.html" > List< / a > < / li >
< li > < a href = "map.html" > Map< / a > < / li >
< li > < a href = "null.html" > Null< / a > < / li >
< / ul >
< / td >
< td >
< ul >
< li > < a href = "num.html" > Num< / a > < / li >
< li > < a href = "object.html" > Object< / a > < / li >
< li > < a href = "range.html" > Range< / a > < / li >
< li > < a href = "sequence.html" > Sequence< / a > < / li >
< li > < a href = "string.html" > String< / a > < / li >
< li > < a href = "system.html" > System< / a > < / li >
< / ul >
< / td >
< / tr >
< / table >
< / nav >
< main >
< h1 > System Class< / h1 >
< p > The System class is a grab-bag of functionality exposed by the VM, mostly for
use during development or debugging. < / p >
< h2 > Static Methods < a href = "#static-methods" name = "static-methods" class = "header-anchor" > #< / a > < / h2 >
< h3 > System.< strong > clock< / strong > < a href = "#system.clock" name = "system.clock" class = "header-anchor" > #< / a > < / h3 >
< p > Returns the number of seconds (including fractional seconds) since the program
was started. This is usually used for benchmarking. < / p >
< h3 > System.< strong > gc< / strong > () < a href = "#system.gc()" name = "system.gc()" class = "header-anchor" > #< / a > < / h3 >
< p > Requests that the VM perform an immediate garbage collection to free unused
memory. < / p >
< h3 > System.< strong > print< / strong > () < a href = "#system.print()" name = "system.print()" class = "header-anchor" > #< / a > < / h3 >
< p > Prints a single newline to the console. < / p >
< h3 > System.< strong > print< / strong > (object) < a href = "#system.print(object)" name = "system.print(object)" class = "header-anchor" > #< / a > < / h3 >
2015-12-30 08:13:38 -08:00
< p > Prints < code > object< / code > to the console followed by a newline. If not already a string,
2015-11-09 08:01:19 -08:00
the object is converted to a string by calling < code > toString< / code > on it. < / p >
2017-10-19 07:05:45 -07:00
< div class = "codehilite" > < pre > < span > < / span > < span class = "vg" > System< / span > < span class = "o" > .< / span > < span class = "n" > print< / span > < span class = "p" > (< / span > < span class = "s" > " I like bananas" < / span > < span class = "p" > )< / span > < span class = "output" > I like bananas< / span >
2015-11-09 08:01:19 -08:00
< / pre > < / div >
< h3 > System.< strong > printAll< / strong > (sequence) < a href = "#system.printall(sequence)" name = "system.printall(sequence)" class = "header-anchor" > #< / a > < / h3 >
2015-12-30 08:13:38 -08:00
< p > Iterates over < code > sequence< / code > and prints each element, then prints a single newline
2015-11-09 08:01:19 -08:00
at the end. Each element is converted to a string by calling < code > toString< / code > on it. < / p >
2017-10-19 07:05:45 -07:00
< div class = "codehilite" > < pre > < span > < / span > < span class = "vg" > System< / span > < span class = "o" > .< / span > < span class = "n" > printAll< / span > < span class = "p" > ([< / span > < span class = "mi" > 1< / span > < span class = "p" > ,< / span > < span class = "p" > [< / span > < span class = "mi" > 2< / span > < span class = "p" > ,< / span > < span class = "mi" > 3< / span > < span class = "p" > ],< / span > < span class = "mi" > 4< / span > < span class = "p" > ])< / span > < span class = "output" > 1[2, 3]4< / span >
2015-11-09 08:01:19 -08:00
< / pre > < / div >
< h3 > System.< strong > write< / strong > (object) < a href = "#system.write(object)" name = "system.write(object)" class = "header-anchor" > #< / a > < / h3 >
< p > Prints a single value to the console, but does not print a newline character
afterwards. Converts the value to a string by calling < code > toString< / code > on it. < / p >
2017-10-19 07:05:45 -07:00
< div class = "codehilite" > < pre > < span > < / span > < span class = "vg" > System< / span > < span class = "o" > .< / span > < span class = "n" > write< / span > < span class = "p" > (< / span > < span class = "mi" > 4< / span > < span class = "o" > +< / span > < span class = "mi" > 5< / span > < span class = "p" > )< / span > < span class = "output" > 9< / span >
2015-11-09 08:01:19 -08:00
< / pre > < / div >
< p > In the above example, the result of < code > 4 + 5< / code > is printed, and then the prompt is
printed on the same line because no newline character was printed afterwards. < / p >
< / main >
< / div >
< footer >
< div class = "page" >
< div class = "main-column" >
< p > Wren lives
< a href = "https://github.com/munificent/wren" > on GitHub< / a >
— Made with ❤ by
< a href = "http://journal.stuffwithstuff.com/" > Bob Nystrom< / a > and
< a href = "https://github.com/munificent/wren/blob/master/AUTHORS" > friends< / a > .
< / p >
< div class = "main-column" >
< / div >
< / footer >
< / body >
< / html >