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

Performative wards #46

Closed
eelstork opened this issue Sep 29, 2022 · 0 comments · Fixed by #50
Closed

Performative wards #46

eelstork opened this issue Sep 29, 2022 · 0 comments · Fixed by #50
Milestone

Comments

@eelstork
Copy link
Collaborator

When passing null arguments to functions returning status, in general intended behaviour is to either cancel or condone the task; sometimes the function itself can make an informed decision; sometimes it makes more sense for the caller to decide.

Example:

task Attack(target, weapon) => Equip(weapon) && Strike(target);

A good implementation of Equip should not fail silently. Then, assuming a bare-handed attack is acceptable, let's use the ? unary operator:

# Will condone Equip (do not invoke; return true) if 'weapon' is null
task Attack(target, weapon) => Equip(weapon?) && Strike(target);

Meanwhile the above function wouldn't be good if it made an agent equip a weapon while no target is defined; in this case, use the ! operator to fail early if a null is passed as target:

# Fail and do not run the task if 'target' is null
task Attack(target!, weapon) => Equip(weapon?) && Strike(target);
@eelstork eelstork added this to the Alpha milestone Sep 29, 2022
@eelstork eelstork changed the title Null wards in status func invocations and function declarations Performative wards Sep 29, 2022
This was referenced Sep 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant