List/File of all language keywords?


#1

Hi, i noticed that “this” and “self” seem to-be supported, yet i could not find any documentation that “self” should even work. So is there a generated or updated list of all reserved keywords?

thx
Andy


#2

You can find a list of all reserved keywords listed in FSkookumScriptGeneratorHelper::ms_reserved_keywords located in SkookumScriptGeneratorBase.inl. Currently these are:

  • branch
  • case
  • change
  • eh
  • else
  • exit
  • false
  • if
  • loop
  • nil
  • race
  • random
  • rush
  • skip
  • sync
  • this
  • this_class
  • this_code
  • this_mind
  • true
  • unless
  • when
  • and
  • nand
  • nor
  • not
  • nxor
  • or
  • xor

Note: self is not a reserved keyword, it’s a method of Object.
Note: Yup, eh is reserved. :sk: is a Canadian language. :grin:

These are all the words reserved by SkookumScript though not all of them are currently used, Some such as skip are for planned commands in the future.


#3

this is the mechanism to refer to the current owner object just like C++ and many other languages.

As for self(), there are some methods that do not return the receiver object even though you really want them to, so self allows you to work around that. For example say you have a method do_stuff() that does not return the receiver. You can write it and self() in a call cascade (multiple methods on the same receiver): obj.[do_stuff self]

Since methods can be called without brackets if they don’t need arguments self() can look like it is a reserved word self. There are a few things that can help you here. First of all, the SkookumIDE will use syntax highlighting to set reserved words apart from methods and temporary variables - they are colored in light green.

Another thing you can do in the SkookumIDE is press Alt+G when the edit caret is on an identifier and if it is a method it should pop you to the definition of the method.

Given the confusion of this/self it might be a good idea to change self() to something more obviously a method such as this_result(). It is quite rarely used anyway.

In addition to the reserved words posted by @GreatGuru above, you can also look through the SkookumScript syntax to see all the reserved words of SkookumScript.


#4

ok thx for the self() explanation.