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

Explain $! and $/ in start block #2804

Merged
merged 3 commits into from Jun 8, 2019
Merged

Explain $! and $/ in start block #2804

merged 3 commits into from Jun 8, 2019

Conversation

Altai-man
Copy link
Member

Addresses start blocks and thunks get fresh $/ and $! from 6.d changelog.

On the other hand, I am not sure where we can indicate thunks part. Any ideas?

doc/Language/control.pod6 Outdated Show resolved Hide resolved
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.
Copy link
Contributor

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.

Copy link
Member Author

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 $/ and $!", while it is totally unclear where we can or if we even should note the thunks part.

Copy link
Contributor

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.

Copy link
Contributor

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! :)

Copy link
Contributor

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?

Copy link
Member Author

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.

@Altai-man Altai-man merged commit a6612c2 into master Jun 8, 2019
@Altai-man Altai-man deleted the note-start-special-vars branch June 8, 2019 12:54
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 this pull request may close these issues.

None yet

3 participants