From b583ed1d19116c568e48600043fc108899a52bbd Mon Sep 17 00:00:00 2001 From: Glen Whitney Date: Thu, 19 Sep 2024 01:56:49 +0000 Subject: [PATCH] Remove multi-let statements from Husht in favor of lat on every line, per discussion with Aaron. --- Examples.md | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/Examples.md b/Examples.md index a871b75..e4fda0f 100644 --- a/Examples.md +++ b/Examples.md @@ -71,10 +71,10 @@ fn main let logical: bool = true let a_float: f64 = 1.0 // Regular annotation - an_integer = 5i32 // Suffix annotation + let an_integer = 5i32 // Suffix annotation let default_float = 3.0 // `f64` - default_integer = 7 // `i32` + let default_integer = 7 // `i32` // Can infer from another line; here i64: let mut inferred_type = 12 @@ -282,13 +282,13 @@ struct Rectangle fn main // Create struct with field init shorthand let name = s"Peter" //! Note s-string - age = 27 - peter = Person name, age + let age = 27 + let peter = Person name, age println! "{:?}", peter let point: Point = Point x: 10.3, y: 0.4 - another_point: Point = Point x: 5.2, y: 0.2 + let another_point: Point = Point x: 5.2, y: 0.2 println! "point coordinates: ({}, {})", point.x, point.y @@ -398,10 +398,10 @@ fn inspect(event: WebEvent) fn main let pressed = WebEvent::KeyPress 'x' - pasted = WebEvent::Paste s"my text" - click = WebEvent::Click x: 20, y: 80 - load = WebEvent::PageLoad - unload = WebEvent::PageUnload + let pasted = WebEvent::Paste s"my text" + let click = WebEvent::Click x: 20, y: 80 + let load = WebEvent::PageLoad + let unload = WebEvent::PageUnload inspect pressed inspect pasted @@ -635,9 +635,10 @@ fn main //! following the `let z=`, without the `scope` //! keyword this would merely be `let z = 2 * x` //! (2) The final semicolon is allowed and preserved - //! by Husht to suppress the return value from - //! the scope, but returning the last expression - //! from a scope is the default for Husht + //! by Husht to suppress the return value from the + //! scope, but returning the last expression from a + //! scope is the default for Husht except in the final + //! statement of a function typed to return Unit let z = scope // Final semicolon discards value; `z` ← `()` 2 * x;