Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add comment explaining "." vs. ":" handling
From: #692 > It took me a bit of digging the back history to try to remember why `.` and > `:` have separate handlers. Of course, in Lua, `:` is just syntactic sugar. In > Teal, however, we have in the language semantics separate concepts for > functions and record-functions/methods, because the latter are statically > bound to their records. > > For example, want to be able to detect that the programmer made a typo and a > method name is invalid, and that means that we need, at one point of the code, > to declare that the declarations of methods are done. So you can only do > `function my_record:mymethod` in the same scope where you created your record, > for instance. > > Internally, Teal does keep track if a function "is a method" (that is, if it > was declared with `:` or `.`; in more recent versions, we even check if a > function is method-like by having a first argument `self` with its own type). > This is to keep the door open for future enhancements to the type system, such > as interfaces (see this comment: > #97 (comment)). > > So, it's an explicit decision to not make `:` just a syntactic sugar for `.`, > like Lua.
- Loading branch information