microsoft / microsoft/pxt-arcade

Named functions not accessible within function

Open
#329 1 comment 0 reactions 1 assignee View on GitHub

@mmoskal is already working on this.

Since Dec 10, 2019.

p2 typescript
Dominant language
TypeScript
Stars
546
Forks
263
Avg merge
7h 35m
Merged PRs (30d)
46

Description

Is your feature request related to a problem? Please describe.

named functions (outside of function declarations) can't refer to themselves. This makes names in function expressions

Example:

let hi = function hello() {
    alert("hi!");
    if (Math.random() < .5) {
        hello();
    }
}

hi();

Arcade

(emphasis on the recursive call to hello to make it splash potentially more than once; possible in typescript, but not in pxt)

Describe the solution you'd like

Either add in the named functions behavior as in typescript or document as a minor difference in makecode.com/language / highlight the name in the function expression as not supported (unless it's used in other cases that I haven't thought of)

Just a minor difference I noticed while writing up an appendix lesson on anonymous functions

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.