Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hacklang command line program in strict mode

Is there any way to create command line programs in strict mode of Hack? As Hack's strict mode does not allow statements outside a function I can't call my main function.

(This is rather a theoretical question as it is easy to circumvent the problem by having a non-strict file to call the main function.)

like image 836
Csq Avatar asked Apr 13 '14 01:04

Csq


1 Answers

It's currently not possible to write a project (command line program or otherwise) 100% in Hack strict mode due to this limitation. You will indeed need to have some bootstrap code in the toplevel ("pseudomain"), which strict currently just does not allow. The reason for this is that toplevel code is basically impossible to statically typecheck, since everything is a global and can be changed behind the scenes at any time by any code.

However the end result is silly and something we want to fix eventually -- there is, for example, no reason to prevent a single call to a function with no parameters, i.e., exactly what you need to immediately get out of pseudomain and into a function.

like image 139
Josh Watzman Avatar answered Oct 16 '22 01:10

Josh Watzman