Skip to content
This repository has been archived by the owner on Sep 23, 2020. It is now read-only.

Implement Closure Capture #27

Open
LemonHX opened this issue May 10, 2020 · 0 comments
Open

Implement Closure Capture #27

LemonHX opened this issue May 10, 2020 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@LemonHX
Copy link
Member

LemonHX commented May 10, 2020

我觉得我可以这样实现:

  • 首先用编译器确认这个闭包引用的变量的位置
  • 然后,把那个变量变成ref类型并扔到堆里
  • 最后在运行那个闭包的时候从堆里取出他的引用

难点:

  • 如果Async分支被合并就需要一个机制去确保堆里面信息的正确性(比如锁,STM
  • 改动堆里的值并不是引用而是拷贝,只要是被引用的变量都进堆。。。感觉有点浪费
@LemonHX LemonHX added the enhancement New feature or request label May 10, 2020
@LemonHX LemonHX added this to the Release the alpha edition milestone May 10, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants