Revamp private/public functions

Problem: having public as the default makes it very easy to accidentally
export local function by forgetting the `private` modifier.

Solution: functions are private by default and must be declared as `entrypoint`s
to be exported. So `entrypoint foo() = ...` instead of `function foo() = ...`.

We still accept the `private` modifier although it is redundant.
This commit is contained in:
Ulf Norell
2019-06-27 12:10:25 +02:00
parent dd5fc17554
commit 79137e058e
7 changed files with 110 additions and 24 deletions
+2 -2
View File
@@ -253,7 +253,7 @@ insert_call_function(Code, Call, FunName, Args, Options) ->
[ Code,
"\n\n",
lists:duplicate(Ind, " "),
"stateful function ", Call,"() = ", FunName, "(", string:join(Args, ","), ")\n"
"stateful entrypoint ", Call, "() = ", FunName, "(", string:join(Args, ","), ")\n"
]).
-spec insert_init_function(string(), options()) -> string().
@@ -263,7 +263,7 @@ insert_init_function(Code, Options) ->
lists:flatten(
[ Code,
"\n\n",
lists:duplicate(Ind, " "), "function init() = ()\n"
lists:duplicate(Ind, " "), "entrypoint init() = ()\n"
]).
last_contract_indent(Decls) ->