Git Product home page Git Product logo

proposals's Introduction

ECMAScript proposals

ECMAScript Internationalization API Specification proposals

Contributing to proposals

Active proposals

Proposals follow this process document. This list contains only stage 2 proposals and higher that have not yet been withdrawn/rejected, or become finished. Stage 2 indicates that the committee expects these features to be developed and eventually included in the standard.

Stage 3

Proposal Author Champion Test262 Feature Flag Last Presented
Legacy RegExp features in JavaScript Claude Pache Mark Miller
Claude Pache
legacy-regexp May 2017
JSON Modules Myles Borins
Sven Sauleau
Dan Clark
Daniel Ehrenberg
Myles Borins
Sven Sauleau
Dan Clark
Daniel Ehrenberg
json-modules January 2021
Temporal Philipp Dunkel
Maggie Johnson-Pint
Matt Johnson-Pint
Brian Terlson
Shane Carr
Ujjwal Sharma
Philip Chimento
Jason Williams
Justin Grant
Philipp Dunkel
Maggie Johnson-Pint
Matt Johnson-Pint
Brian Terlson
Shane Carr
Ujjwal Sharma
Philip Chimento
Jason Williams
Justin Grant
Temporal March 2021
Decorators Daniel Ehrenberg
Kristen Hewell Garrett
Kristen Hewell Garrett decorators March 2023
JSON.parse source text access Richard Gibson Richard Gibson json-parse-with-source January 2023
RegExp Modifiers Ron Buckton Ron Buckton regexp-modifiers June 2022
Array.fromAsync J.S. Choi J.S. Choi Array.fromAsync May 2023
Sync Iterator helpers Gus Caplan Michael Ficarra
Jonathan Keslin
Kevin Gibbons
iterator-helpers November 2022
Explicit Resource Management Ron Buckton Ron Buckton explicit-resource-management March 2023
Float16 on TypedArrays, DataView, Math.f16round Leo Balter Leo Balter
Kevin Gibbons
May 2023
Decorator Metadata Kristen Hewell Garrett Kristen Hewell Garrett May 2023
Import Attributes Myles Borins
Sven Sauleau
Dan Clark
Daniel Ehrenberg
Sven Sauleau
Dan Clark
Daniel Ehrenberg
Nicolò Ribaudo
import-attributes March 2023
Source Phase Imports Luca Casonato Guy Bedford
Luca Casonato
July 2023
Uint8Array to/from Base64 Kevin Gibbons Kevin Gibbons February 2024
Dynamic Code Brand Checks Nicolo Ribaudo Krzysztof Kotowicz
Mike Samuel</br />Nicolo Ribaudo
April 2024
Redeclarable global eval-introduced vars Shu-yu Guo Shu-yu Guo April 2024

Stage 2.7

Proposal Author Champion Test262 Feature Flag Last Presented
ShadowRealm Caridy Patiño
Jean-Francois Paradis
Dave Herman
Mark Miller
Caridy Patiño
Leo Balter
Rick Waldron
Chengzhong Wu
ShadowRealm February 2024
Promise.try Jordan Harband Jordan Harband April 2024
Math.sumPrecise Kevin Gibbons Kevin Gibbons April 2024

Stage 2

Proposal Author Champion Last Presented
function.sent metaproperty Allen Wirfs-Brock HE Shi-Jun July 2019
throw expressions Ron Buckton Ron Buckton January 2018
Function implementation hiding Domenic Denicola
Michael Ficarra
Michael Ficarra June 2020
collection normalization Bradley Farias Bradley Farias January 2019
Array.isTemplateObject Mike Samuel, Krzysztof Kotowicz Krzysztof Kotowicz December 2019
Map.prototype.emplace Bradley Farias Erica Pramer July 2020
Dynamic Import Host Adjustment Mike Samuel, Krzysztof Kotowicz Krzysztof Kotowicz December 2019
Record & Tuple Robin Ricard
Richard Button
Robin Ricard
Richard Button
December 2021
Module Expressions Surma
Daniel Ehrenberg
Nicolò Ribaudo
Surma
Nicolò Ribaudo
November 2022
Pipeline Operator J. S. Choi
James DiGioia
Ron Buckton
Tab Atkins
J. S. Choi
Ron Buckton
Tab Atkins
August 2021
Destructure Private Fields Justin Ridgewell Justin Ridgewell December 2021
RegExp Buffer Boundaries (\A, \z, \Z) Ron Buckton Ron Buckton December 2021
String.dedent Misha Kaletsky
Hemanth HM
Justin Ridgewell
Hemanth HM
Justin Ridgewell
June 2022
JSON.parseImmutable Robin Ricard
Richard Button
Nicolò Ribaudo
Ashley Claymore
Robin Ricard
Richard Button
Nicolò Ribaudo
Ashley Claymore
July 2022
Module Declarations Daniel Ehrenberg
Nicolò Ribaudo
Daniel Ehrenberg
Mark Miller
Nicolò Ribaudo
November 2022
Symbol Predicates Robin Ricard
Jordan Harband
Ashley Claymore
Jordan Harband
January 2023
Async Iterator helpers Gus Caplan Michael Ficarra
Jonathan Keslin
Kevin Gibbons
January 2023
Iterator.range Jack Works Jack Works March 2023
Async Context Chengzhong Wu Chengzhong Wu
Justin Ridgewell
March 2023
Time Zone Canonicalization Justin Grant Justin Grant
Richard Gibson
May 2023
Deferring Module Evaluation Yulia Startsev
Guy Bedford
Yulia Startsev
Guy Bedford
Nicolò Ribaudo
July 2023
RegExp.escape Domenic Denicola
Benjamin Gruenbaum
Jordan Harband
Jordan Harband
Kevin Gibbons
September 2023
Joint Iteration Michael Ficarra Michael Ficarra February 2024

The test262 feature flag links to a code search of tests using that feature flag, which may constitute complete or partial coverage. The ❓ means there is no feature flag for tests yet.

Contributing to proposals

See Contributing to ECMAScript and How We Work for the most up-to-date information on contributing to proposals to TC39 standards and how proposals advance.

Onboarding proposals

Proposals that are Stage 1 and above must be transferred to the TC39 GitHub organization for discoverability and archival purposes. To onboard a proposal:

  1. Transfer your repository to the @tc39-transfer organization
    • if you are a TC39 delegate, but not a member of that organization, please contact @LJHarb
  2. The Github Administrator, or one of the chairs, will transfer your repository to the TC39 organization the next chance they get.

Note that as part of the onboarding process your repository name may be normalized. Don't worry, repo redirects will continue to work as long as you never create a fork, or a new repository, with the same name - although Github Pages redirects will be broken (please update your links!).

proposals's People

Contributors

bterlson avatar chicoxyzzy avatar cmgchess avatar codehag avatar ctcpip avatar decompil3d avatar dnalborczyk avatar domenic avatar erights avatar frankyftang avatar gibson042 avatar gsathya avatar hemanth avatar jasnell avatar keithamus avatar leobalter avatar littledan avatar ljharb avatar mathiasbynens avatar michaelficarra avatar mikesamuel avatar mstade avatar mylesborins avatar ptomato avatar rbuckton avatar sebmarkbage avatar septs avatar sosukesuzuki avatar syg avatar tschneidereit avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

proposals's Issues

Proposal for Array.depth property to get depth of nested array.

How about an inbuilt function to find the depth of an array, There is already an Experimental feature Array.prototype.flatten(depth) which accepts a depth value up to which array needed to be flatten
But there is no inbuilt way to get the depth of an array. Currently to get the depth we have to do something like. which is an implicit way to get depth.

function depthOf(arr) {
    if(!Array.isArray(arr))
        throw "Not an Array"
    var depth = 1;
    var i;
    for(var i = 0; i< arr.length; i++){
        if (!Array.isArray(arr[i])) continue;

        if(Array.isArray(arr[i])){
            var depth = depthOf(arr[i]) + 1;
            depth = Math.max(depth, depth);
        }
    }
    return depth;
}

If there is option to get depth explicitely that would be great. We already have property of array like Array.length why not have another property like Array.depth.

If we would have Array.depth property then code can look something like this.

Note: below example caontains an experimental method of array Array.prototype.flatten()

var arr1 = [1, 2, [3, 4, [5, 6]]];
arr1.flatten(arr1.depth);
// [1, 2, 3, 4, 5, 6]

Missing info?

Unable to find details of the below:

  • 64-Bit Integer Operations.

  • Null Propagation Operator got renamed to Optional Chaining?

Required function parameters with `!`

function add(x, y) {
    // ... 
}
add();

The following code throws no error and assigns undefined to x and y in the body of the call. I am proposing using ! on the right to show parameters that are required. This would also apply for class methods and constructors. And can be mixed with existing function declarations for allowing optional parameters that may or may not have default values

Example

function fetch(url!, headers) {
    // ...
}

Use prettier to format md files

It could be nice to have precommit hooks for md formatting to prevent noise in PR diffs. husky + prettier should fit well. WDYT?

constructorof

I really down't know this submission proposal thing.

I have troubles with Monanding javascript and strategies choosing.

simple
if(symbol constructorof class) would save hours of work.

Thank you for implementation.

Tooling implementation status

Links to "Tooling implementation status" issues for some proposals, so people can see whether their tools support the proposals. I check them when they are supported in WebStorm, Babel and Flow.

By tool

Distinguish authors from champions

Can we please add an “author” column and distinguish authors from champions?

Context: I’m championing multiple proposals from community members. I don’t want credit for writing these proposals, though. It feels wrong to conflate being a champion with authorship.

Despite me explicitly mentioning the proposal authors during each of my presentations, some committee members mistakenly thought I was the author.

I’ve seen similar confusion in articles and blog posts about proposals, where a champion was credited as an author, based on the table in this repository.

Listing RegExp.escape

It could be worthwhile to list the RegExp.escape proposal with the inactive ones to make it more discoverable; it's still relevant and there's agreement about how to proceed with it, just no one's done the work.

Question: What does a finished proposal imply?

Hi! I'm just someone who wants to know a bit more about the process, and hopefully this will be useful if someone else stumbles on to this.

Could someone explain what a finished proposal implies? Taking dynamic imports for example (just moved to finished_proposals.md in #217), I believe an implementation has already landed in most browsers and nodejs under the --experimental-modules flag. Were these implementations updated alongside this proposal document? Does this proposal being finished mean that there will be no more modifications to the spec in any of the implementations? Does it indicate that these features will be marked stable in nodejs soon?

Proposal: sugar syntax for structuring

I often see objects created like this:

const obj = {
  isMuted: state.volume.isMuted
};

this proposal is to allow this equivalent syntax instead:

const obj = {
  state.volume.isMuted
};

The last key isMuted of the state.volume.isMuted expression will be set as a key on the new object.

Block params current status

Not an issue but is it possible to know the current status of the block params proposal? It hasn’t been updated for over a year now and I received no answers from the person in charge (@samuelgoto) when I asked for more information.

Thanks

Compile proposal statistics at different stages

Stage Total proposals Active proposals Inactive proposals
0 125 11 22
1 125 11 22
2 125 11 22
3 125 11 22
4 125 11 22

Such summary statistics will be helpful to developers, eg. to decide whether to adopt a proposal at stage 0 by examining the failure rate of stage 0 proposals (in the above example, it will be 22/125 = 17%).

It can be further broken down into past 1-year, 3-year, lifetime statistics etc.

Difficulty tracking proposals via Active Proposals table

Hello all,

I am starting to have real trouble following the active proposals through this repo. The problem seems to be that there are proposals that have been on there and stuck at say stage 1 for a very long time. Possibly it would be helpful to have an additional column to show the last meeting each one was discussed in or even the last time the spec repo was updated.

What do you do with proposals that have been accepted to stage 1 or greater but are lacking in strong interest and/or have champions who are actively working on other proposals. Perhaps there should be an "at-risk" column for proposals that have sat without movement for a few cycles.

Whatever the solution is I think it would be helpful if that list was being pruned in some way.

Difficulty in seeking proposals in meeting notes

Hi Folks 🖐️,

I was searching for proposals in meeting notes for my last improvement about "last presented columns". It is really hard to find anything in these notes. Do you have any plans for this? For this like, building a website or implementing these notes in an existing website would be a better solution. It's really painful this way and it's getting more complex each addition. Therefore, it can be implemented in the future.

I talked to some UX Designers about this repo, they will share their opinions soon. Besides, maybe we can ask them what we can improve on the beta website.

Proposal Dynamic Table/Columns with Voting-System

I'm not sure where to suggest it, so I'll write it here

How about if we provide a Tool like Trello in which we list the Proposals in the respective Stage and then the community can vote on what features they want mostly
For example, you could see which proposals are well received by the community and where priority could be given

If there is already a place for it, can you link it here please?

Problem: Can’t tell if proposals are actually finished, inactive, or what, just from looking at the proposals themselves

Concrete problem: Looking at https://github.com/tc39/proposal-trailing-function-commas, I can’t tell it’s in the “finished” state. Same for https://github.com/tc39/Array.prototype.includes. Etc.

I realize https://github.com/tc39/proposals/blob/master/finished-proposals.md can tell me — and https://github.com/tc39/proposals/blob/master/inactive-proposals.md for inactive ones — if I’m somebody who happens to already know to look there. But I’m sure many people don’t know that.

That risks causing confusion and wasting peoples’ time trying to figure out what the state is.

So it’d be helpful if something like this could happen:

It’d also be helpful of the group could consider adopting and documenting a policy that requires the above actions to happen.

Remove rocket?

I'm not sure how useful the "rocket" column is. It doesn't seem to be very up-to-date. Generally, the agendas are a more frequently updated data source for what's proposed for advancement. Should we remove this column?

A fresh look at date-time and timezone logic.

Given the massive works that have been done to improve and enhance the language, it's time to give timezone and date-time logic an updated approach. I'm not sure where to even start with this, but I was thinking it might be nice to get something similar to moment.js + moment-timezone inside JavaScript proper... perhaps Moment to correspond to Date with a nod to the library.

I'm not suggesting it follow the moment library completely, but it might be a nice place to consider... An alternative may be more additions to Date but I'm not sure that it's a good idea. I'd also suggest that some minimal formats are accepted, and some behaviors established.

  • Symbol constants for parts of time (Moment.DAYS, Moment.MONTHS, ...) in code, used for Date-time math... ex: someMoment.add(5, Moment.DAYS)
  • Immutable by default, any method should return a new instance not mutate the underlying value.
  • Timezone support, this is crucial, and I know it's huge to polyfill, so would be essential to getting browser vendors on board.
  • .toZone(timezoneId = localZone) - instance from one timezone to another, with time adjustment
  • .asZone(timezoneId = localZone) - instance zone changed to another, without time adjustment
    *.format(formatString) - string formatting, including localization constructs/convensions
  • parsing strings, ISO-8601 format must be used, or a specific format string must be specified, UTC is default unless a zone is specified as part of the string, can use toZone/asZone to make a local time instance.

Work with the moment.js team to create a new version as a polyfill that aligns with the proposed design, I know that there's been talk about going immutable in particular, and there's been a lot of good work there.

Array.forEach should return promise

I have a proposal as forEach function of array should return a promise of void. As the function is async, while coupling it with asynchronous "behavior" and yield is not working.

Mutual exclusivity of Defensible Classes/Class Fields, functional `import()`/Nested Imports

This may or may not be the right place to open this issue. In addition, this is more of a list of questions than it is a definitive issue against one of more proposals or proposal definitions.

Class Fields has provisions for privatizing fields within classes. It is unclear to me based on reading the proposal whether the ability to privatize a field with a "#" extends to methods. Nevertheless, the link to Defensible Classes is broken and has been for some time. What provisions would defensible classes provide that Class Fields would not with the exception of perhaps privatizing methods. Perhaps preventing the definition/redefinition of the class and it's methods/members?

In addition, they're certainly not expressly mutually exclusive, but I cannot see the value provided by the duplicity of a proposal for nested import statements and for a functional import. Doesn't the progression of import() to stage 3 imply that the TC believes that it is objectively better than the alternative? Does this not somewhat invalidate the nested import proposal?

Object field name shorthand

Allow .s to be included in object field names so that you can short hand field names.

Examples:

var obj = {
    field1: "val",
    field2.field3: "val2"
};

becomes

var obj = {
    field1: "val",
    field2: {
        field3: "val2"
   }
};
var obj = {
    field1: "val",
    field2.field3: "val2",
    field2.field4: "val3"
};

would equal

var obj = {
    field1: "val",
    field2: {
        field3: "val2",
        field4: "val3"
   }
};

and even

var obj.field = "val";

becomes

var obj = {
    field: "val"
};

Correct minus sign is not interpreted as minus

The minus sign, (U+2212) is not correctly recognized in JavaScript as minus:

10 − 4
// Yields: SyntaxError: illegal character
10 - 4
// Yields: 6

Is this an issue? Depends. Technically? No, is not in the standard keyboard layout, oddly. The issue comes to screen readers, i.e. readers used by blind or visually impaired programmers that code. Screen readers will read the normal - in -1000 as: "Dash thousand", but if is used, the screen reader will read: "Minus thousand".

Another example is:

1000 − 100
// Screen reader: "Thousand minus hundred"
1000 - 100
// Screen reader: "Thousand dash hundred"

I think I need some more detail to back this up, but this is at my thoughts on this subject.

I am a fan of correctness and I would like to see JavaScript recognizing the correct symbols :)

Clarify Stage 0 proposals requirements

I'm not sure where this issue should be, but:

  • tc39/proposals/stage-0-proposals.md claims that champion is required for stage 0 proposal
    • [Stage 0 proposals] are "planned to be presented to the committee by a TC39 champion"
    • All stage 0 proposals have TC39 champions
  • tc39/proposals/README.md links to tc39/process-document as authoritative
  • tc39/process-document/index.html claims that champion is required for stage 1 proposal.
    • Champion must be identified to advance to stage 1
    • No champion is required for stage 0
  • tc39/ecma262 agrees with tc39/proposals/stage-0-proposals.md.

Some of these documents should be fixed, and I'm not sure which ones.

June meeting notes

Any chance you could publish the June meeting notes on the repo?

On the README.md:

  • Intl.DurationFormat says June 2020 but the link points to the February notes.
  • Intl.Enumeration API and Smart Unit Preferences in Intl.NumberFormat reached stage 1 in June 2020 but they're no link to the notes

esdiscuss.org problem

Not sure if this is place to discuss about this.
In esdiscuss.org, it says to send message to specific email, when I posted, I haven't received any replies, or anything and I checked esdiscuss.org and my post doesn't exist there.

add a reviewers column in stage 2 table

We (are supposed to) assign reviewers to proposals as they move from stage 1 to stage 2. In order for a proposal to advance to stage 3, these reviewers must sign off on the spec text. We sometimes forget to assign reviewers, and sometimes forget who we assigned. This column will help us keep track of that.

On a related note, does anyone know who was supposed to review the function implementation hiding proposal? I couldn't find anything in the notes.

Destructuring for grabbing elements - `getDestructuredElementsByIds()` function

Currently we have to do like

// Grab the elemenets
const name1 = document.getElementById('name1');
const name2 = document.getElementById('name2');
const score1 = document.getElementById('score1');
const score2 = document.getElementById('score2');
const current1 = document.getElementById('current1');
const current2 = document.getElementById('current2');
const btnNew = document.getElementById('btnNew');
const btnRoll = document.getElementById('btnRoll');
const btnHold = document.getElementById('btnHold');
const dice = document.getElementById('dice');

Some Destructuring function would be useful
Example

const [name1, name2] = document.getDestructuredElementsByIds();

which should be equal to

const name1 = document.getElementById('name1');
const name2 = document.getElementById('name2');

Add controversial mark

Add special mark (like 🚀) for controversial proposals, which need extra attention before been implemented, require more constructive discussion or should be delayed.

Built-in `deepCopy/deepClone` Prototype for both objects and iterable objects (based on the structured cloning algorithm)

I have been working on a project where we had a serious serious need of deep copy.

The work out that me and my mentor did was this
https://codepen.io/IamManchanda/pen/XYpVPY?editors=0012

screen shot 2018-07-13 at 12 22 25 pm


But here is the catch,
How I did it doesn't matter but what matters is that I have felt that everyone who is working on a complex app with frameworks like angular, vue and react would need such function


Reason why I think so strongly that everyone in javascript community needs this is this
=> https://gist.github.com/search?l=JavaScript&q=deepcopy
=> https://gist.github.com/search?l=JavaScript&q=deepclone
=> https://github.com/search?l=JavaScript&q=deepcopy&type=Repositories
=> https://github.com/search?l=JavaScript&q=deepclone&type=Repositories


And thus I decided to post this on lodash lodash/lodash#3822
But here is what the author felt about it

Thanks for the suggestion. I'm happy to defer to user-land packages for this. My hope is that a built-in deep clone comes to browsers and Node (based on the structured cloning algorithm) then there would be no need for user-land implementations.

I think he is right ... I personally feel like a good way to do this would be to add a built-in deepCopy Prototype for both objects and iterable objects
That being said, if you guys think that good place would be Global Built-in's then that's great too

Anyways my case implementation could be like

const harry = {
  name: 'Harry Manchanda',
  age: 25,
  social: [
    {
      website: 'twitter',
      username: '@harmanmanchanda',
    },
    {
      website: 'facebook',
      username: 'IamManchanda',
    },
  ],
};

// Object.prototype.deepCopy(), Array.prototype.deepCopy(), etc
const dev = harry.deepCopy();
dev.social[1].website = 'github'; 

console.log(harry);
console.log(dev);

which will output ...

screen shot 2018-07-13 at 12 40 07 pm

A method to fire :hover and :active states

Because emulating (dispatchEvent) of mouse events (mouseenter, mouseover, mousedown) doesn't fire :hover nor :active CSS states we need a methods to toggle :active and :hover states. Like Element.focus() toggles :focus and Element.blur() removes :focus state.

I write web App and I can translate touch* events into series of left mouse buttons clicks but without visual effects like hovered and activated states. It is annoying for me like for other 34 persons registered on Stack Overflow.

Native ZIP

As applications are moving to the cloud more file formats require zipping and unzipping to conserve space (e.g. Excel).
There are a couple of Zip implementations but they are all a bit awkward ones. JSZip has bugs. zip.js is unsupported. Sometimes they hang on big archives, etc.
Not to mention they are about 100 KB in size (e.g. jszip.min.js).
Perhaps it would make sense for browsers to add native Zip class.
And also file streaming could be a thing for handling large files.

const unzip = new Zip.Decompress()
unzip.on('entry', entry => ...)
file.createReadableStream().pipe(unzip)
const zip = new Zip.Compress()
const file = File.initiateOutputStream('file.zip')
if (!file) return
zip.pipe(file)
zip.push('entry1', Blob|String)
zip.close()

Reopen if needed.

"ArrayBuffer.transfer" proposal is listed both in "Stage 0" and "inactive"

Although not explicitly stated, it seems like there's an implicit distinction between active stage 0 proposals and inactive ones, where only active ones are in the "Stage 0" list.

The ArrayBuffer.transfer proposal seems to be a sole exception to this, however. Was this intentional, or just a mistake?

Inconsistency in data type behaviors in javascript

Wierd behaviors,
1)
const x = {...a, key:true}

Throws error ‘a’ is undefined, but

let a //not assigned, which is undefined now

const x = {...a, key: true}

Doesn’t throw error even when typeof a is undefined

Same goes with this scenario,

If we declare variable as undefined,

let a = undefined

And concatenate with other string,

let x = a + ‘test’ // outputs ‘undefinedtest’

Why is data type is getting concatenated?

What about adding new language features to enable writing DSL with Javascript

Love the capability in Kotlin which you can write your own DSL:

Examples:

Things like generating model:

val people = People {
     name = "albert"
     job = {
          company = "NZ"
          title = "Dev"
    }
}

Or handling logic:

    permissionRequestHandler {
        actualRequestCode = requestCode
        expectRequestCode = this.requestCode
        
        onSuccess {
            // Do something when success
        }

        onFailure {
            // Do something for the failure case
        }

        onNeverAskAgain {
            
        }
    }

And you can do something like this:

html {
    body {
         div {
          }
    }
}

The best part is that these DSL are nothing more than plain Kotlin, it's just the syntax layer which makes it looks like a DSL. So you can actually add other normal Kotlin code into it.

By doing this, it enables Domain Driven Design better in the language level. You can describe your core business logic in a hunman readable way. And even your marketing team can customize it. The only abstraction is the part that can be re-used across modules, but you can customize the other parts around it.

Needed syntax support

It requires 2 features:

1. When the last parameter of a function is lambda, you can do this:

fun takeLambda( callback: () -> Unit ) {
     callback()
}

// Instead of calling it like this:
takeLambda ({
     // declare the lambda body
})

// you can do this
takeLambda {
    // put your lambda here
}

// Lambda can take parameter, when there is only one, its name will be `it`
takeLambda { it ->
    // put your lambda here
}

// even call it implictly
takeLambda {
   it.name = "ok"
}

2. Declare a receiver(Context) for the function

// We now enable the People context on this lambda
fun takeLambda( callback: People.() -> Unit ) {
     callback()
}

// Assume there is a People.name property, then you can do this
// Because the lambda got that context now
takeLambda {
      name = "albert"
}

Then you can write your own DSL.

This is pretty huge feature which will enable tons of great idea and cool new syntax to solve particular problem.

A little bit more

To make it more declarative, there is another infix function concept in Kotlin.

// if we have a function like this:
infix fun People.add(s: String) { /* ... */ }
    
// Then we can do this:
AnyPeopleObject add "abc"

I previously used a mock library which uses these features to create some very good DSL to mock:

every {
     FuncCall()
} returns 2

Can we do this in Javascript ?

Sorry if I post in the wrong place.
Love Javascript and want it to evolve better.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.