-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
stdlib: create an init function for records with complex default values
records that have field default values containing variables that are "free" was unsafe in functions that have variables with the same name. This commit creates init function for records to protect the variables in the default value. e.g. -record(r, {f = fun(X)->case X of {y, Y} -> Y; _ -> X end, g=..., h=abc}). foo(X)->\#r{}. --> foo(X)->(r_init()){}. r_init() will only initialize fields that will not be updated e.g. foo(X)->\#r{f=X} --> foo(X)->(r_init_f()){f=X}. r_init_f will only initialize g and h with its default value, f will be initialized to undefined. r_init() functions will not be generated if all fields of the record that contains "free variables" are initialized by the user. e.g. foo(X)->\#r{f=X,g=X}. --> foo(X)->{r,X,X,abc}.
- Loading branch information
1 parent
0ff9d32
commit d544c98
Showing
4 changed files
with
100 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters