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
Explain $! and $/ in start block #2804
Conversation
doc/Language/control.pod6
Outdated
| say $promise.result; # OUTPUT: «42» | ||
|
|
||
| Note that code executed this way does not have access to special variables L«C<$!>|/syntax/$!» | ||
| and L«C<$/>|/syntax/$/» of its outer block, but receives new ones. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if it's worth mentioning the motivation for this: so that regex matches and try expressions executed in the asynchronous task will have their per-task state.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmmm, we probably should. Also, can you please explain thunks part? I know the term in its general meaning, we even have a glossary item, but in fact it tells no useful info, and the changelog entry says "start blocks and thunks get fresh
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When we have start { blah } it's obvious that there's a new scope there: the start has a block. But when we have start blah there's no visible block there, but in fact we are creating an object of type Code that contains the blah. That Code object - which doesn't map to any visible block in the code - is the thunk.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, and the reason we must do this is because we don't want blah to execute now, but over on the thread pool - which is the point of start! :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not resolved yet, right? Can you please take a look and solve it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is not, thanks for reminding.
I will address it a bit later today.
Addresses
start blocks and thunks get fresh $/ and $!from 6.d changelog.On the other hand, I am not sure where we can indicate
thunkspart. Any ideas?