winglang / wing

A programming language for the cloud ☁️ A unified programming model, combining infrastructure and runtime code into one language ⚡
https://winglang.io
Other
4.6k stars 180 forks source link

feat(compiler)!: explicit lift qualification statement #6400

Open yoav-steinberg opened 2 weeks ago

yoav-steinberg commented 2 weeks ago

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

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

github-actions[bot] commented 2 weeks ago

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
monadabot commented 2 weeks ago

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

Last Updated (UTC) 2024-05-05 08:12
monadabot commented 2 weeks ago

Benchmarks

Comparison to Baseline ⬜⬜⬜🟩🟩⬜🟩🟩⬜⬜🟩⬜⬜ | Benchmark | Before | After | Change | | :-- | --: | --: | --: | | version | 56ms±0.52 | 56ms±0.6 | +0ms (+0.86%)⬜ | | functions_1.test.w -t sim | 411ms±22.98 | 401ms±9.37 | -9ms (-2.31%)⬜ | | functions_1.test.w -t tf-aws | 823ms±4.18 | 818ms±7.82 | -6ms (-0.69%)⬜ | | jsii_big.test.w -t sim | 2810ms±15.61 | 2770ms±17.89 | -40ms (-1.43%)🟩 | | jsii_big.test.w -t tf-aws | 3037ms±14.05 | 2990ms±12.19 | -47ms (-1.56%)🟩 | | functions_10.test.w -t sim | 487ms±16.31 | 482ms±9.17 | -4ms (-0.92%)⬜ | | functions_10.test.w -t tf-aws | 2094ms±14.42 | 2000ms±10.03 | -94ms (-4.5%)🟩 | | jsii_small.test.w -t sim | 384ms±2.13 | 368ms±2.87 | -15ms (-3.99%)🟩 | | jsii_small.test.w -t tf-aws | 619ms±5.95 | 609ms±7.64 | -9ms (-1.53%)⬜ | | empty.test.w -t sim | 368ms±6.38 | 359ms±3.69 | -9ms (-2.48%)⬜ | | empty.test.w -t tf-aws | 606ms±6.14 | 589ms±4.91 | -18ms (-2.9%)🟩 | | hello_world.test.w -t sim | 400ms±4.59 | 395ms±3.15 | -5ms (-1.22%)⬜ | | hello_world.test.w -t tf-aws | 1507ms±7.39 | 1512ms±8.7 | +6ms (+0.37%)⬜ | ⬜ 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|56ms|56ms|58ms|1ms|1ms| |functions_1.test.w -t sim|401ms|384ms|432ms|9ms|13ms| |functions_1.test.w -t tf-aws|818ms|803ms|839ms|8ms|11ms| |jsii_big.test.w -t sim|2770ms|2744ms|2836ms|18ms|25ms| |jsii_big.test.w -t tf-aws|2990ms|2969ms|3020ms|12ms|17ms| |functions_10.test.w -t sim|482ms|456ms|494ms|9ms|13ms| |functions_10.test.w -t tf-aws|2000ms|1982ms|2027ms|10ms|14ms| |jsii_small.test.w -t sim|368ms|362ms|376ms|3ms|4ms| |jsii_small.test.w -t tf-aws|609ms|594ms|634ms|8ms|11ms| |empty.test.w -t sim|359ms|352ms|366ms|4ms|5ms| |empty.test.w -t tf-aws|589ms|577ms|598ms|5ms|7ms| |hello_world.test.w -t sim|395ms|387ms|401ms|3ms|4ms| |hello_world.test.w -t tf-aws|1512ms|1498ms|1535ms|9ms|12ms|
Last Updated (UTC) 2024-05-05 08:17