wing icon indicating copy to clipboard operation
wing copied to clipboard

feat(compiler)!: explicit lift qualification statement

Open yoav-steinberg opened this issue 1 year ago • 3 comments

fixes #6080

Initial implementation of the explicit lift statement as defined in the rfc.

let bucket = new cloud.Bucket();
inflight () => {
  let b = bucket; // Assing preflight object to inflight variable
  lift {bucket: put} {
    b.put("k","v"); // Within this block we can use the inflight variable because of the explicit lifting above
  }
  b.put("k","v"); // This is an error, because it's outside the explicit lift block and we can't figure out who `b` is
  
  // We can also define multiple lifts in a block and multiple ops per lift
  lift {bucket1: [put, get], bucket2: delete} { ... }
  
  // We can nest lift blocks
  lift {bucket1: put} {
    ..
    lift {bucket2: get} {
      ..
    }
  }

  // Type checker validates passed methods are really part of the inflight interface of the object
  lift {bucket: leak} {}
              //^ err: leak isn't an inflight method on type Bucket
}

Breaking change: this is instead of the lift() builtin macro that was used for the same purpose.

Checklist

  • [x] Title matches Winglang's style guide
  • [x] Description explains motivation and solution
  • [x] Tests added (always)
  • [x] Docs updated (only required for features)
  • [ ] Added pr/e2e-full label if this feature requires end-to-end testing

By submitting this pull request, I confirm that my contribution is made under the terms of the Wing Cloud Contribution License.

yoav-steinberg avatar May 02 '24 18:05 yoav-steinberg

Thanks for opening this pull request! :tada: Please consult the contributing guidelines for details on how to contribute to this project. If you need any assistence, don't hesitate to ping the relevant owner over Discord.

Topic Owner
Wing SDK and utility APIs @chriscbr
Wing Console @ainvoner, @skyrpex, @polamoros
JSON, structs, primitives and collections @hasanaburayyan
Platforms and plugins @hasanaburayyan
Frontend resources (website, react, etc) @tsuf239
Language design @chriscbr
VSCode extension and language server @markmcculloh
Compiler architecture, inflights, lifting @yoav-steinberg
Wing Testing Framework @tsuf239
Wing CLI @markmcculloh
Build system, dev environment, releases @markmcculloh
Library Ecosystem @chriscbr
Documentation @hasanaburayyan
SDK test suite @tsuf239
Examples @hasanaburayyan
Wing Playground @eladcon

github-actions[bot] avatar May 02 '24 18:05 github-actions[bot]

Console preview environment is available at https://wing-console-pr-6400.fly.dev :rocket:

Last Updated (UTC) 2024-05-19 09:18

monadabot avatar May 02 '24 18:05 monadabot

Benchmarks

Comparison to Baseline 🟥⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜
Benchmark Before After Change
version 57ms±0.52 59ms±0.59 +2ms (+3.43%)🟥
functions_10.test.w -t sim 498ms±11.48 511ms±14.04 +13ms (+2.52%)⬜
functions_10.test.w -t tf-aws 2074ms±14.05 2112ms±22.77 +38ms (+1.83%)⬜
hello_world.test.w -t sim 407ms±5.54 418ms±8.98 +11ms (+2.76%)⬜
hello_world.test.w -t tf-aws 1456ms±7.36 1472ms±4.84 +16ms (+1.1%)⬜
functions_1.test.w -t sim 410ms±4.56 399ms±5.19 -10ms (-2.56%)⬜
functions_1.test.w -t tf-aws 846ms±6.9 831ms±7.33 -15ms (-1.8%)⬜
jsii_big.test.w -t sim 2840ms±8.24 2826ms±16.58 -14ms (-0.48%)⬜
jsii_big.test.w -t tf-aws 3072ms±14.47 3054ms±9.21 -18ms (-0.58%)⬜
empty.test.w -t sim 370ms±3.94 374ms±5.45 +4ms (+1.14%)⬜
empty.test.w -t tf-aws 604ms±3.9 607ms±3.49 +4ms (+0.64%)⬜
jsii_small.test.w -t sim 380ms±4.59 383ms±3.59 +3ms (+0.81%)⬜
jsii_small.test.w -t tf-aws 622ms±5.13 625ms±5.68 +4ms (+0.62%)⬜

⬜ Within 1.5 standard deviations 🟩 Faster, Above 1.5 standard deviations 🟥 Slower, Above 1.5 standard deviations

Benchmarks may vary outside of normal expectations, especially when running in GitHub Actions CI.

Results
name mean min max moe sd
version 59ms 58ms 61ms 1ms 1ms
functions_10.test.w -t sim 511ms 484ms 542ms 14ms 20ms
functions_10.test.w -t tf-aws 2112ms 2051ms 2149ms 23ms 32ms
hello_world.test.w -t sim 418ms 404ms 451ms 9ms 13ms
hello_world.test.w -t tf-aws 1472ms 1460ms 1480ms 5ms 7ms
functions_1.test.w -t sim 399ms 393ms 412ms 5ms 7ms
functions_1.test.w -t tf-aws 831ms 813ms 841ms 7ms 10ms
jsii_big.test.w -t sim 2826ms 2788ms 2864ms 17ms 23ms
jsii_big.test.w -t tf-aws 3054ms 3040ms 3078ms 9ms 13ms
empty.test.w -t sim 374ms 358ms 383ms 5ms 8ms
empty.test.w -t tf-aws 607ms 598ms 613ms 3ms 5ms
jsii_small.test.w -t sim 383ms 374ms 389ms 4ms 5ms
jsii_small.test.w -t tf-aws 625ms 608ms 635ms 6ms 8ms
Last Updated (UTC) 2024-05-19 09:24

monadabot avatar May 02 '24 19:05 monadabot

Thanks for contributing, @yoav-steinberg! This PR will now be added to the merge queue, or immediately merged if yoav/explicit_lift_qual_v2 is up-to-date with main and the queue is empty.

mergify[bot] avatar May 19 '24 09:05 mergify[bot]

Congrats! :rocket: This was released in Wing 0.74.0.

monadabot avatar May 19 '24 10:05 monadabot