by pansa2 · 1y ago · 0 comments
It seems that these are (unsound) type hints, years before TypeScript made them cool:
> "If your program tries to put one type of value in a variable which was designed to hold another type of value, Pike may detect this" [emphasis mine]
https://pike.lysator.liu.se/docs/tut/fundamentals/index.md#t...
There is a strict_types mode that will increase warnings/errors.
One of the problems with Pike is that the mechanics of this and other things are effectively undocumented so you have to learn by experimenting and reading the source.
A more subtle issue with type hints (as in TypeScript/Python, not sure if this applies to Pike) is that there are ways to work around the type system. You can get, for example, a variable of type `int` that actually holds a `list`:
Also you'd think having the type signature would help with performance, but in some cases it can cause the VM to enforce a runtime type check where it wouldn't have before, imposing worse performance.
At least it might be shooting Nulls.