From a1118c332cf393d91e562e573c5ddde340910dc5 Mon Sep 17 00:00:00 2001 From: Bob Nystrom Date: Sun, 6 Apr 2014 08:38:00 -0700 Subject: [PATCH] IO.write -> IO.print in docs. --- doc/site/branching.markdown | 20 ++++++++++---------- doc/site/method-calls.markdown | 2 +- doc/site/syntax.markdown | 14 +++++--------- doc/site/variables.markdown | 14 +++++++------- 4 files changed, 23 insertions(+), 27 deletions(-) diff --git a/doc/site/branching.markdown b/doc/site/branching.markdown index 9b34e476..ca895fd0 100644 --- a/doc/site/branching.markdown +++ b/doc/site/branching.markdown @@ -19,27 +19,27 @@ This means `0`, empty strings, and empty collections are all considered "true" v The simplest branching statement, `if` lets you conditionally skip a chunk of code. It looks like this: :::wren - if (ready) IO.write("go!") + if (ready) IO.print("go!") That evaluates the parenthesized expression after `if`. If it's true, then the statement after the condition is evaluated. Otherwise it is skipped. Instead of a statement, you can have a block: :::wren if (ready) { - IO.write("getSet") - IO.write("go!") + IO.print("getSet") + IO.print("go!") } You may also provide an `else` branch. It will be executed if the condition is false: :::wren - if (ready) IO.write("go!") else IO.write("not ready!") + if (ready) IO.print("go!") else IO.print("not ready!") And, of course, it can take a block too: if (ready) { - IO.write("go!") + IO.print("go!") } else { - IO.write("not ready!") + IO.print("not ready!") } ## The logical operators `&&` and `||` @@ -49,13 +49,13 @@ The `&&` and `||` operators are lumped here under branching because they conditi An `&&` ("logical and") expression evaluates the left-hand argument. If it's falsey, it returns that value. Otherwise it evaluates and returns the right-hand argument. :::wren - IO.write(false && 1) // false - IO.write(1 && 2) // 2 + IO.print(false && 1) // false + IO.print(1 && 2) // 2 An `||` ("logical or") expression is reversed. If the left-hand argument is truthy, it's returned, otherwise the right-hand argument is evaluated and returned: :::wren - IO.write(false || 1) // 1 - IO.write(1 || 2) // 1 + IO.print(false || 1) // 1 + IO.print(1 || 2) // 1 **TODO: Conditional operator.** diff --git a/doc/site/method-calls.markdown b/doc/site/method-calls.markdown index 98ca4185..c36df9cc 100644 --- a/doc/site/method-calls.markdown +++ b/doc/site/method-calls.markdown @@ -6,7 +6,7 @@ Wren is object-oriented, so most code consists of method calls. Most of them look like so: :::wren - IO.write("hello") + IO.print("hello") items.add("another") items.insert(1, "value") diff --git a/doc/site/syntax.markdown b/doc/site/syntax.markdown index 4e72abf9..64980d19 100644 --- a/doc/site/syntax.markdown +++ b/doc/site/syntax.markdown @@ -26,7 +26,7 @@ Some people like to see all of the reserved words in a programming language in one lump. If you're one of those folks, here you go: :::dart - break class else false fn for if in is + break class else falsefor if in is null return static this true var while ## Statement terminators @@ -38,17 +38,13 @@ never write `;` unless you want to cram a bunch of statements on one line. :::dart // Two statements: - IO.write("hi") - IO.write("bye") + IO.print("hi") + IO.print("bye") Sometimes, though, a statement doesn't fit on a single line and treating the newline as a semicolon would trip things up. To handle that, Wren has a very simple rule: It ignores a newline following any token that can't end a -statement. Specifically, that means any of these: - - :::dart - ( [ { . , * / % + - | || & && ! ~ = < > <= >= == != - class else if is static var while +statement. Everywhere else, a newline is treated just like a `;`. Note that this is a very different system from how JavaScript handles semicolons. If you've been burned @@ -70,7 +66,7 @@ Identifiers that start with underscore (`_`) are special in Wren. They are used **TODO: Move this somewhere else:* -### The `is` operator +## The `is` operator The `is` keyword can be used as an infix operator in expression. It performs a type test. The left operand is an object and the right operand is a class. It diff --git a/doc/site/variables.markdown b/doc/site/variables.markdown index 0f4fce73..23f750c6 100644 --- a/doc/site/variables.markdown +++ b/doc/site/variables.markdown @@ -12,7 +12,7 @@ defined, it can be accessed by name as you would expect. :::dart var animal = "Slow Loris" - IO.write(animal) // Prints "Slow Loris". + IO.print(animal) // Prints "Slow Loris". ## Scope @@ -21,11 +21,11 @@ defined until the end of the block where that definition appears. :::dart { - IO.write(a) // ERROR! a doesn't exist yet. + IO.print(a) // ERROR! a doesn't exist yet. var a = 123 - IO.write(a) // "123" + IO.print(a) // "123" } - IO.write(a) // ERROR! a doesn't exist anymore. + IO.print(a) // ERROR! a doesn't exist anymore. Variables defined at the top level of a script are *global*. All other variables are *local*. Declaring a variable in an inner scope with the same name as an @@ -36,9 +36,9 @@ something you likely intend to do much). var a = "outer" { var a = "inner" - IO.write(a) // Prints "inner". + IO.print(a) // Prints "inner". } - IO.write(a) // Prints "outer". + IO.print(a) // Prints "outer". Declaring a variable with the same name in the *same* scope *is* an error. @@ -63,6 +63,6 @@ assigned value. :::dart var a = "before" - IO.write(a = "after") // Prints "after". + IO.print(a = "after") // Prints "after". **TODO: Forward references for globals, closures.**