strath/sm-test-files/animals-example/animal.sm

27 lines
678 B
Text
Raw Normal View History

2021-12-16 09:08:08 +00:00
&& ++name declares a class
&& '++name declares an abstract class
&& all of that is, of course, a statement so ¡!
2021-12-16 09:40:06 +00:00
'++animal (
2021-12-16 09:08:08 +00:00
&& +}}type{{ declares a property of a class
&& "+}}type{{ declares a static property of a class
¡"+}}string{{ name!;
¡+}}string{{ speed!;
&& ### declares the constructor
2021-12-16 09:40:06 +00:00
### /}}string{{ name\ /speed\ | (
2021-12-16 09:08:08 +00:00
¡<=/"Created animal named " + name\!;
&& +var refers to a property, like this. in other languages
&& you can only assign values to static variables once in this language
¡+name < name!;
¡+speed < speed!;
2021-12-16 09:40:06 +00:00
)
2021-12-16 09:08:08 +00:00
&& +# declares a method
2021-12-16 09:40:06 +00:00
+#walk /distance\ | (
2021-12-16 09:08:08 +00:00
¡<=/¿+name + " walked " + (+speed * +distance)?\!;
2021-12-16 09:40:06 +00:00
)
)