Hacklang: How do I type-annotate a local/global variable? -
the hack manual makes clear how type-annotate function parameters, function return types, , member variables. however, of ways i've tried type-annotate global variable or function-local variable result in syntax error:
string $foo = "foo"; // unexpected t_variable $foo : string = "foo"; // unexpected ':' string $foo; $foo = "foo"; // unexpected t_variable $foo : string; $foo = "foo"; // unexpected ':' are such annotations possible? if possible, correct syntax? if not possible, design or developers plan implement? (it useful.)
it's not possible, , design.
local variables have types inferred, , global variables don't type checked (as can changed @ time anywhere accesing $_globals).
if there's particular page of documentation make clearer, please click "file documentation bug" link @ bottom of it, can added.
Comments
Post a Comment