Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • S sweet-core
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 62
    • Issues 62
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 4
    • Merge requests 4
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • sweet-js
  • sweet-core
  • Merge requests
  • !246

revised withSyntax to update the patternEnv directly

  • Review changes

  • Download
  • Email patches
  • Plain diff
Merged Tim Disney requested to merge better-with-syntax into master Feb 07, 2014
  • Overview 6
  • Commits 7
  • Pipelines 0
  • Changes 6

Rather than have withSyntax be an expansion of syntaxCase use the approach of #216 but localized rather than trying to simulate the full lexical scope of a let binding.

To get a sense of how it works:

function foo() {
    return withSyntax ($y = [makeValue(42, null)]) {
        return withSyntax ($z = [makeValue(100, null)]) {
            return #{$x + $y + $z}
        }
    }
}

expands:

function foo() {
    return function () {
        var res = function () {
                match.patternEnv = patternModule.extendEnv(match.patternEnv);
                match.patternEnv['$y'] = {
                    level: 0,
                    match: [makeValue(42, null)]
                };
                return function () {
                    var res$2 = function () {
                            match.patternEnv = patternModule.extendEnv(match.patternEnv);
                            match.patternEnv['$z'] = {
                                level: 0,
                                match: [makeValue(100, null)]
                            };
                            return patternModule.transcribe(getTemplate(339), name_stx, match.patternEnv);
                        }();
                    match.patternEnv = match.patternEnv.parent;
                    return res$2;
                }();
            }();
        match.patternEnv = match.patternEnv.parent;
        return res;
    }();
}

@natefaubion does this look good to you?

Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: better-with-syntax