-
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: allow variables in record definitions
create an init function e.g. rec_init$^0, for each record with definitions containing variables. e.g. -record(r, {f = fun(X)->case X of {y, Y} -> Y; _ -> X end, g=..., h=abc}). foo(X)->\#r{}. --> foo(X)->(rec_init()){}. rec_init() will initialize all fields with the default values e.g. foo(X)->\#r{f=X} --> foo(X)->(rec_init()){f=X}. This means that some fields will be initialized twice. This also means that if you have side effects in the record definition they might be evaluated even when the corresponding field is set to a new expression. rec_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}. - removes lint error for variables in definitions - updates erl_lint_SUITE and erl_expand_records_SUITE to work with this new behavior
- Loading branch information
1 parent
befaffa
commit cf5cbab
Showing
6 changed files
with
190 additions
and
46 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
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
Oops, something went wrong.