Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7973221
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T08:03:09+00:00 2026-06-04T08:03:09+00:00

Quoted from the Adobe ColdFusion 10: Using closures documentation : function helloTranslator(String helloWord) {

  • 0

Quoted from the Adobe ColdFusion 10: Using closures documentation:

function helloTranslator(String helloWord) 
{ 
    return function(String name) 
    { 
        return "#helloWord#, #name#"; 
    }; 
}

How to scope helloWord and name properly on the return line? Are they both in Arguments scope? If that’s the case, they must be unique?

The Closures and functions section also mentions there are 4 more scopes on top of the already long scope search:

In closure, following is the order of search for an unscoped variable:

  1. Closure’s local scope
  2. Closure’s arguments scope
  3. Outer function’s local scope if available
  4. Owner function’s local scope if available
  5. ColdFusion built-in scope

If I scope something as 'local.', would it search 1 only, or 1,3 & 4?

BTW, I understand Closure & Outer. Who is Owner?

Thank you


Update: Enhancement Request filed: ColdFusion 10.0 – Feature 3191742

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T08:03:10+00:00Added an answer on June 4, 2026 at 8:03 am
        function helloTranslator(String helloWord) 
        { 
          return function(String name) 
          { 
            return "#helloWord#, #name#"; 
          }; 
        }
    

    Here helloWord and name cannot be scoped. There is an implicit Owner scope with “closures defined within a function” which is the local scope of declaring (parent) function, where these variables are present. So these variables must be unique (within function) to be accessed from closures.

    In closure, search for an unscoped variable goes through:

    1. Closure’s local scope
    2. Closure’s arguments scope
    3. Outer/Owner function’s local scope if available
    4. Outer/Owner function’s argument scope if available
    5. Variables scope (available at the time of closure’s creation)
    6. ColdFusion built-in scope

    If something is scoped as Local, in a closure, it would search in 1 only. AFN there is no way to directly scope for 3,4.

    p.s. as said earlier Owner scope is nothing but an implicit scope which points to a cached copy of parent/outer function’s local scope at the time of closure’s creation.

    p.s. You may log an enhancement with ColdFusion to make this scope explicit.

    An example of different scopes is as follows. Run this and you shall understand how closure would use differnt scopes.

    any function exampleClosureForm(arg1){
    
        function x(innerArg1,innerArg2){
            //var arg1= 50;// will hide parent's arg1 if declared
            writedump(arguments);// would dump closure's
            writedump(local);// would dump closure's
            writedump(session.a); // would be same session shared across
            writedump(arg1); // would dump parents argument arg1
            return session.a-- + innerArg1+innerArg2+arg1--;// decrementing to see its behavior for successive call
        };  
        writeoutput(x(1,2));
        writedump(arguments,"browser","html",false,"function");// would dump parent's
        writedump(local,"browser","html",false,"function");// would dump parent's
        arg1 = -100; // since closure is sharing the parent's variable, this change should get reflected
        return x;
    }
    session.a = 10;
    a = exampleClosureForm(10);
    writeoutput("now the calls <br>"); 
    writeoutput(a(innerArg1=5,innerArg2=5)); 
    writeoutput("<br>");
    // with argumentcollection
    argsColl = structNew();
    argsColl.innerArg1= 1;
    argsColl.innerArg2= 3;
    writeoutput(a(argumentCollection = argsColl));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Quoted from ngx_hash.c : ngx_strlow(elt->name, names[n].key.data, names[n].key.len); Which copies the lower case string to
Quoted from this page : send(url: String, target: String, [method: String]) Sends the variables
I want to extract the quoted substrings from inside a string. This is an
I was trying to get all quoted ( or ') substrings from a string
The following saying is quoted from this article in MSDN. ... strong-name signing makes
As far as I understand, applications made with Adobe AIR have been blocked from
Quoted from here : If delimiter contains a value that is not contained in
Consider the following example quoted from php manual for DateTime <?php $date = new
reading this https://developers.google.com/in-app-payments/docs/tutorial Quoted from the above page: Because you sign the JWT using
Quoted from mysql.pm : 3 package DBD::mysql; 4 use strict; 。。。。 17 $err =

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.