diff --git a/doc/sample/Blocks.im b/doc/sample/Blocks.im index ad3a45c..d251e46 100644 --- a/doc/sample/Blocks.im +++ b/doc/sample/Blocks.im @@ -1,9 +1,9 @@ pkg2 = { - onEnter => [ + on-enter => [ cout put:'start!' ], - onExit => [ + on-exit => [ cout put:'end!' ] }. diff --git a/doc/sample/CaesarCipher.im b/doc/sample/CaesarCipher.im index 1bf92fd..c2e27a3 100644 --- a/doc/sample/CaesarCipher.im +++ b/doc/sample/CaesarCipher.im @@ -15,32 +15,31 @@ while true do end end -shiftWidth = 0 +shift-width = 0 while true do cout print:'Shift size: ' cout flush - shiftStr = '' - cin get:shiftStr + shift-str = cin read-line. - if shiftStr == '' then + if shift-str == '' then continue end try - shiftWidth = Int parse:shiftStr - catch (#err:number_format, err) + shift-width = Int parse:shift-str + catch ($err:number-format, err) continue end break end -encodedMessage = '' +encoded-message = '' for c in message do - i = c toOrdinal + i = c to-ordinal sub = 0 if i >= 65 && i <= 90 then @@ -50,16 +49,16 @@ for c in message do else continue end - + i -= sub - i += shiftWidth + i += shift-width if i >= 26 then i -= 26 end - c2 = i toChar - encodedMessage += c2 + c2 = i to-char + encoded-message += c2 end -cout put:encodedMessage +cout put:encoded-message diff --git a/doc/sample/Exception.im b/doc/sample/Exception.im index 4ee7948..e09856c 100644 --- a/doc/sample/Exception.im +++ b/doc/sample/Exception.im @@ -1,7 +1,7 @@ try x = 0 --v = Int parse:'342' -catch ($err:number_format, err) in +catch ($err:number-format, err) in x = 1 --cout put:'Cannot parse integer string ({err})' catch (_, err) in diff --git a/doc/sample/Expressions.im b/doc/sample/Expressions.im index 7ce26ec..419e73d 100644 --- a/doc/sample/Expressions.im +++ b/doc/sample/Expressions.im @@ -1,12 +1,12 @@ -y = 1 + 2 * 3 / 4 * 5 - 6 + 7 multiplyBy:2. -z = w = 2 + 3 multiplyBy:2. -x = (((1 + 2 * 3) multiplyBy:3) add: 5) + 2. -x = ((1 + 2 * 3) multiplyBy:3). +y = 1 + 2 * 3 / 4 * 5 - 6 + 7 multiply-by:2. +z = w = 2 + 3 multiply-by:2. +x = (((1 + 2 * 3) multiply-by:3) add: 5) + 2. +x = ((1 + 2 * 3) multiply-by:3). p = 5 multiply(by:3, add:(2 + 1)). q = 10 squared squared. p1 - setAge:2 squared squared + 4 squared multiply(by:2, add:4 + 1 * 3) + set-age:2 squared squared + 4 squared multiply(by:2, add:4 + 1 * 3) in:"mon" + "ths". m = xz multiply(by:3 add:2) squared. @@ -20,7 +20,7 @@ x = OrderedCollection new yourself. age = Person new(name:"John Doe", age:34) - setAge:144 inUnit:"months"; + set-age:144 in-unit:"months"; ageInMonths. x = 5. @@ -76,10 +76,10 @@ pkg = { 1, 2, 3, 4, 5 }. pkg = { 10, 2 => "Hello", 9, 5 => "World", 14 }. pkg = { { 0 }, { 1 }, { y for y in huh } }. -pkg = { x multiplyBy:2 for x in wow if x > 2 }. +pkg = { x multiply-by:2 for x in wow if x > 2 }. pkg->x = 32. -k = (1 multiplyBy:2, 4). +k = (1 multiply-by:2, 4). for (x, y) in pkg do cout put:'{x}: {y}' @@ -97,11 +97,11 @@ v = pkg->x. v = pkg at:'x'. pkg2 = { - onEnter => [ + on-enter => [ cout put:'start!' ], - onExit => [ + on-exit => [ cout put:'end!' ] }. diff --git a/doc/sample/Person.im b/doc/sample/Person.im index 1e33091..18bbf65 100644 --- a/doc/sample/Person.im +++ b/doc/sample/Person.im @@ -58,13 +58,13 @@ class Person - age | ^self::age. - - ageInMonths | ^self::age * 12. + - age-in-months | ^self::age * 12. - - setName:name | self::name = name. + - set-name:name | self::name = name. - - setAge:age | self::age = age. + - set-age:age | self::age = age. - - setAge:age inUnit:units + - set-age:age in-unit:units match units in $years => self::age = age, $months => self::age = age / 12, @@ -72,7 +72,7 @@ class Person _ => self::age = 0 end! - - getAgeInUnit:units + - get-age-in-units:units ^match units in $years => self::age, $months => self::age / 12, @@ -104,12 +104,12 @@ class Person is converted to the lambda [ :x | self::val = x ] */ - -> exampleProperty | get => self::val, set => self::val = value. + -> example-property | get => self::val, set => self::val = value. /* Without the lambda synthesis, the property would look like this: Note that this is the only time it is legal to access private fields via `self` from a lambda. */ - -> exampleProperty | + -> example-property | get => [ ^self::val ], set => [ :x | self::val = x ]. @@ -119,7 +119,7 @@ class Person If either the `set` or `get` elements are not provided, the property becomes read-only or write-only respectively */ - -> exampleProperty2 | get => 42. + -> example-property-2 | get => 42. /* A property can also be configured to act just like a regular variable, by setting the getter and setters to default implementations. @@ -131,15 +131,15 @@ class Person Similarly, the default setter will set the value of a private member variable named by prepending two underscores to the property name (__exampleProperty3 in this case) to the value provided to the setter. */ - -> exampleProperty3 (get, set) + -> example-property-3 (get, set) /* Just like in the earlier examples, either `get` or `set` can be omitted to create a write-only or read-only property respectively */ - -> exampleProperty4 (get) + -> example-property-4 (get) end p1 = Person new(name:'John Doe', age:34). -p1 setAge:100 inUnit:$months. +p1 set-age:100 in-unit:$months. p1 test(param:'Hello', 'World'). @@ -299,7 +299,7 @@ a = (32, 64). try v = Int parse:'342' -catch ($err:number_format, err) in +catch ($err:number-format, err) in cout put:'Cannot parse integer string ({err})' catch (_, err) in cout put:'Unknown error occurred ({err})' @@ -308,7 +308,7 @@ end /* equivalent 'pure' syntax */ [ v = Int parse:'342' ] - on:$err:number_format do:[ :err :data | + on:$err:number-format do:[ :err :data | cout put:'Cannot parse integer string ({err})' ]; onError:[ :err :data | @@ -382,10 +382,10 @@ cout put:'Hello, world!' if x > 10. **/ p1 - setAge:2 squared squared + 4 squared multiply(by:2, add:4 + 1 * 3) + set-age:2 squared squared + 4 squared multiply(by:2, add:4 + 1 * 3) in:'mon' + 'ths'. (p1 - setAge:(((2 squared) squared) + ((4 squared) multiply(by:2, add:(4 + (1 * 3))))) + set-age:(((2 squared) squared) + ((4 squared) multiply(by:2, add:(4 + (1 * 3))))) in:('mon' + 'ths')). /******************************************************************************/ @@ -440,7 +440,7 @@ pkg2 = pkg1 map:[ :x | ^x * 2 ]. **/ age = Person new(name:'John Doe', age:34); - setAge:144 inUnit:$months; + set-age:144 in-unit:$months; ageInMonths. -- age now has the value 144 @@ -448,7 +448,7 @@ age = Person new(name:'John Doe', age:34); age = do x = Person new(name:'John Doe', age:34). - x setAge:144 inUnit:$months. + x set-age:144 in-unit:$months. x ageInMonths end @@ -471,15 +471,15 @@ end **/ p1 = Person new(name:'John Doe', age:34); - setAge:100 inUnit:$months; - yourself:: + set-age:100 in-unit:$months; + yourself /* p1 now contains the Person object */ /* again, with do..end */ p1 = do x = Person new(name:'John Doe', age:34). - x setAge:100 inUnit:$months. + x set-age:100 in-unit:$months. x end. diff --git a/doc/sample/Simple.im b/doc/sample/Simple.im index 897a018..bdb432c 100644 --- a/doc/sample/Simple.im +++ b/doc/sample/Simple.im @@ -1,27 +1,27 @@ -y = 1 + 2 * 3 / 4 * 5 - 6 + 7 multiplyBy:2. -z = w = 2 + 3 multiplyBy:2. -x = (((1 + 2 * 3) multiplyBy:3) add: 5) + 2. -x = ((1 + 2 * 3) multiplyBy:3). +y = -1 + 2 * 3 / 4 * 5 - 6 + 7 multiply-by:2. +z = w = 2 + 3 multiply-by:2. +x = (((1 + 2 * 3) multiply-by:3) add: 5) + 2. +x = ((1 + 2 * 3) multiply-by:3). p = 5 multiply(by:3, add:(2 + 1)). q = 10 squared squared. p1 - setAge:2 squared squared + 4 squared multiply(by:2, add:4 + 1 * 3) + set-age:2 squared squared + 4 squared multiply(by:2, add:4 + 1 * 3) in:"mon" + "ths". m = xz multiply(by:3 add:2) squared. m = xz multiply(by:3 add:2); squared. -x = OrderedCollection new +x = Ordered-Collection new add: 2; add: 4; add: 6; yourself. age = Person new(name:"John Doe", age:34) - setAge:144 inUnit:"months"; - ageInMonths. + set-age:144 in-unit:"months"; + age-in-months. x = 5. q = 10 if x > 2 else 20. diff --git a/doc/sample/String.im b/doc/sample/String.im index a9323f2..81bbe1e 100644 --- a/doc/sample/String.im +++ b/doc/sample/String.im @@ -3,4 +3,4 @@ package net.doorstuck.test s1 = 'hello world' s2 = s1 map:[ :c | ^c uppercase ] -s3 = s1 map:[ :c | ^((c ordinal) + 1) toChar ] +s3 = s1 map:[ :c | ^((c ordinal) + 1) to-char ] diff --git a/doc/sample/Sum.im b/doc/sample/Sum.im index 88cdf4c..5b8165e 100644 --- a/doc/sample/Sum.im +++ b/doc/sample/Sum.im @@ -9,7 +9,7 @@ while true do cout flush. v = 0. - input = cin readLine. + input = cin read-line. if input == '' then break diff --git a/doc/sample/Vehicle.im b/doc/sample/Vehicle.im index 1005b8e..f746b9e 100644 --- a/doc/sample/Vehicle.im +++ b/doc/sample/Vehicle.im @@ -3,8 +3,8 @@ package net.doorstuck.vehicles protocol Vehicle - startup - shutdown - - nrWheels - - nrDoors + - nr-wheels + - nr-doors - turn(direction:dir) - accelerate(direction:dir) - velocity @@ -12,33 +12,33 @@ end class Car - startup - self.engineRunning = true + self.engine-running = true end - shutdown - self.engineRunning = false + self.engine-running = false end - - nrWheels + - nr-wheels ^4 end - - nrDoors + - nr-doors ^4 end - turn(direction:dir) - self.currentDirection = dir + self.current-direction = dir end - accelerate(direction:dir) match dir - #forward => self.currentVelocity += 1, - #backward => self.currentVelocity -= 1, + $forward => self.current-velocity += 1, + $backward => self.current-velocity -= 1, end end - - velicity - ^self.currentVelocity + - velocity + ^self.current-velocity end end