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

Outer dynamic variable not found in nested start block #5669

Open
p6rt opened this issue Sep 13, 2016 · 4 comments
Open

Outer dynamic variable not found in nested start block #5669

p6rt opened this issue Sep 13, 2016 · 4 comments
Labels

Comments

@p6rt
Copy link

p6rt commented Sep 13, 2016

Migrated from rt.perl.org#129263 (status was 'open')

Searchable as RT129263$

@p6rt
Copy link
Author

p6rt commented Sep 13, 2016

From @smls

  ➜ my $*a = 42; await start { say $*a }
  42

  ➜ my $*a = 42; await start { await start { say $*a } }
  Dynamic variable $*foo not found

IRC discussion (rearranged for clarity)​:

  <smls> Are threads supposed to see dynamic variables declared in the
  mainline prior to starting the thread?

  <jnthn> A start block will go the extra mile to make that happen
  <jnthn> It just takes the CALLER​:: of whatever calls Promise.start iirc

  <jnthn> But if you work directly with threads then every one has its
  own fresh dynamic scope

  ...

  <smls> Should that still work, when it's 2 levels deep into `start`?

  <jnthn> Umm...I guess it'd be nice if it worked.
  <jnthn> Can RT it; I don't see why we can't fix that.

@p6rt
Copy link
Author

p6rt commented Sep 13, 2016

From @lizmat

Feels to me some kind of loop would need to be made around line 33 in src/core/stubs.pm, basically looping until we either find the dynamic variable, or look for a $*PROMISE in the context and if so, try to find it there?

Hope this made sense, too deep in other stuff now to try things out myself.

On 13 Sep 2016, at 14​:29, Sam S. (via RT) <perl6-bugs-followup@​perl.org> wrote​:

# New Ticket Created by Sam S.
# Please include the string​: [perl #​129263]
# in the subject line of all future correspondence about this issue.
# <URL​: https://rt-archive.perl.org/perl6/Ticket/Display.html?id=129263 >

➜ my $*a = 42; await start { say $*a }
42

➜ my $*a = 42; await start { await start { say $*a } }
Dynamic variable $*foo not found

IRC discussion (rearranged for clarity)​:

<smls> Are threads supposed to see dynamic variables declared in the
mainline prior to starting the thread?

<jnthn> A start block will go the extra mile to make that happen
<jnthn> It just takes the CALLER​:: of whatever calls Promise.start iirc

<jnthn> But if you work directly with threads then every one has its
own fresh dynamic scope

...

<smls> Should that still work, when it's 2 levels deep into `start`?

<jnthn> Umm...I guess it'd be nice if it worked.
<jnthn> Can RT it; I don't see why we can't fix that.

@p6rt
Copy link
Author

p6rt commented Sep 13, 2016

The RT System itself - Status changed from 'new' to 'open'

@p6rt
Copy link
Author

p6rt commented Sep 14, 2016

From @LLFourn

Looks pretty similar to​:
https://rt.perl.org/Public/Bug/Display.html?id=127033

On Tue, Sep 13, 2016 at 11​:13 PM Elizabeth Mattijsen <liz@​dijkmat.nl> wrote​:

Feels to me some kind of loop would need to be made around line 33 in
src/core/stubs.pm, basically looping until we either find the dynamic
variable, or look for a $*PROMISE in the context and if so, try to find it
there?

Hope this made sense, too deep in other stuff now to try things out myself.

On 13 Sep 2016, at 14​:29, Sam S. (via RT) <perl6-bugs-followup@​perl.org>
wrote​:

# New Ticket Created by Sam S.
# Please include the string​: [perl #​129263]
# in the subject line of all future correspondence about this issue.
# <URL​: https://rt-archive.perl.org/perl6/Ticket/Display.html?id=129263 >

➜ my $*a = 42; await start { say $*a }
42

➜ my $*a = 42; await start { await start { say $*a } }
Dynamic variable $*foo not found

IRC discussion (rearranged for clarity)​:

<smls> Are threads supposed to see dynamic variables declared in the
mainline prior to starting the thread?

<jnthn> A start block will go the extra mile to make that happen
<jnthn> It just takes the CALLER​:: of whatever calls Promise.start
iirc

<jnthn> But if you work directly with threads then every one has its
own fresh dynamic scope

...

<smls> Should that still work, when it's 2 levels deep into `start`?

<jnthn> Umm...I guess it'd be nice if it worked.
<jnthn> Can RT it; I don't see why we can't fix that.

@p6rt p6rt added the conc label Jan 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant