Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Global objects/difficulty testing... #50

Open
PitilessPeanut opened this issue May 4, 2020 · 0 comments
Open

Global objects/difficulty testing... #50

PitilessPeanut opened this issue May 4, 2020 · 0 comments
Assignees
Labels
feature request New feature or request question Further information is requested
Projects

Comments

@PitilessPeanut
Copy link

Not a bug as such, but I came accross some difficulties while testing some functions. Rather than allowing me to pass the state through a pointer, almost all functions rely on global objects. For example, startFunctionParameters() and startFunction() both rely on globals. In startFunction() I got until function_mode->context = malloc(1 + strlen(module_path_stack.arr[module_path_stack.size - parent_context]));. The module_path object (which is also global) requires some complex construction and after commenting out those lines, I reached if (module == NULL && strcmp(function_cursor->module, "") != 0) { (line 221 I think) after that I gave up.
I think improved documentation and a more clear api could help, but having global state spread accross multiple files makes it more difficult to modify or add new functionality to the code.
Perhaps an approach would be to add all globals to a struct Globals {} object which could then be passes to every functtion:
void startFunction(struct Globals *state, char *name, enum Type type)
This is, of course, only one possibility.

@mertyildiran mertyildiran self-assigned this Aug 16, 2020
@mertyildiran mertyildiran added feature request New feature or request question Further information is requested labels Aug 16, 2020
@mertyildiran mertyildiran added this to To do in Chaos via automation Aug 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature or request question Further information is requested
Projects
Chaos
  
To do
Development

No branches or pull requests

2 participants