From 517d661368611fe753e9fd97a7adb2e45fca745e Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Wed, 16 Jan 2019 16:46:38 -0800 Subject: Updating documentation --- examples/how_do_i.nom | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'examples/how_do_i.nom') diff --git a/examples/how_do_i.nom b/examples/how_do_i.nom index 6e5d4d1..d4422f1 100644 --- a/examples/how_do_i.nom +++ b/examples/how_do_i.nom @@ -252,6 +252,17 @@ say both "Very very very very long first argument that needs its own line" # This can be nested: say both (my favorite number) and also "foo" +# Object-oriented programming: +# How do I define a class? +a (Vec) is a thing: + ($its, + $other) means (Vec {.x = ($its.x + $other.x), .y = ($its.y + $other.y)}) + ($its, length) means + sqrt ($its.x * $its.x + $its.y * $its.y) + +$v1 = (Vec {.x = 1, .y = 2}) +assume ($v1 + $v1) == (Vec {.x = 2, .y = 4}) +say $v1 + # Macros: # The "lua>" and "=lua" macros can be used to write raw lua code: (say the time) means: -- cgit v1.2.3