The following simple Promise is vowed and I am not allowed to break it.
my $my_promise = start {
loop {} # or sleep x;
'promise response'
}
say 'status : ', $my_promise.status; # status : Planned
$my_promise.break('promise broke'); # Access denied to keep/break this Promise; already vowed
# in block <unit> at xxx line xxx
Why is that?
Broken promises can harm your relationship since doing so can make your partner lose their trust in you. Moreover, frequently breaking your promises can also make your partner consider you as someone who doesn't keep their word, affecting your relationship as a whole.
First, let's be clear, breaking promises due to being lazy, fearful, or flaky is a personality flaw, and it has consequences. However, if the harm caused by breaking a promise would be less than the harm caused by keeping it, we're morally obligated to break the promise.
Promises are commitmentsPeople with strong relationships rank higher in emotional intelligence and are more likely to stay loyal to their commitments. Whether the commitment is to yourself or to someone else, making a promise is a commitment that you will keep your word. It is a commitment that reinforces trust.
Sometimes we make promises we can't keep. We make them because they seem kinder than the alternative. We don't want to deny people their wishes or tell someone that the thing they want is impossible.
Because the Promise is vowed, you cannot change it: only something that actually has the vow, can break the Promise. That is the intent of the vow
functionality.
What are you trying to achieve by breaking the promise as you showed? Is it to stop the work being done inside of the start
block? Breaking the Promise would not do that. And the vow
mechanism was explicitly added to prevent you from thinking it can somehow stop the work inside a start
block.
If you want work inside a start
block to be interruptible, you will need to add some kind of semaphore that is regularly checked, for instance:
my int $running = 1;
my $my_promise = start {
while $running {
# do stuff
}
$running
}
# do other stuff
$running = 0;
await $my_promise;
Hope this made sense.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With