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 7407373
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T05:42:29+00:00 2026-05-29T05:42:29+00:00

A simple piece of code that should trace : rien test done! and I

  • 0

A simple piece of code that should trace :

  • rien
  • test
  • done!

and I get something completely far away from that,

scenario A :

var __functions_to_execute:Array;

function start():void {
    __functions_to_execute  =[];

    __functions_to_execute.push(futile_trace());
    __functions_to_execute.push(futile_trace('test'));

    execute_functions();
}

function execute_functions():void {
    if(__functions_to_execute.length){
        //where shift on this Array remove the first element and returns it
        var exec:Function =__functions_to_execute.shift();
        exec;

        //I tried this too, just in case
        //__functions_to_execute[0];
        //__functions_to_execute.shift();
    } else  trace("done!");
}

function futile_trace(_value:String ='rien'):void {
    trace(_value);
    execute_functions();
}

start();

pretty simple. but the result is :

  • rien
  • done!
  • test

lets add a deprecated function to this and lets change the futile_trace function to :

function futile_trace(_value:String ='rien'):void {
    trace(_value);
    setTimeout(execute_functions, 0);
}

and then the result is :

  • rien
  • test
  • done!

Ok then, I said to myself, why not, lets change the scope when I call execute_functions, so I tried :

function futile_trace(_value:String ='rien'):void {
    trace(_value);
    extra_step();
}

function extra_step():void {
    execute_functions();
}

guess what was the result?! yeah :

  • rien
  • done!
  • test

so?! Is the trace function that bad? that slow? is it the fact that passing an argument to the function take so much time compare to the other one? I mean… wow!

is there something I can do to avoid this type of weirdness ?

(For the record, my project is not to trace {rien, done and test}… I have 15k lines of codes that react completely differently if I compile them with “Omit trace statements” or not.

Thanks for your input guys.

  • 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-05-29T05:42:30+00:00Added an answer on May 29, 2026 at 5:42 am

    You are executing the functions and adding their return values to the __functions_to_execute array, not the functions themselves.

    Your function execute_functions doesn’t actually do anything. I’ve tried to explain the sequence in-line:

    function start():void {
        __functions_to_execute  =[];
        // 1. traces 'rien' first because futile_trace() is called with no args
        // 2. 'done!' will be traced inside execute_functions because the array is still empty
        // 3.undefined will be pushed into the array next
        __functions_to_execute.push(futile_trace());
        // 4. traces 'test'
        // execute_functions does not trace anything because __functions_to_execute is non-empty
        // but it also doesn't do anything because it is just removing the `undefined` value from the start of the array.
        __functions_to_execute.push(futile_trace('test'));
    
        execute_functions();
    }
    

    Something more like this should behave how you expect. It’s storing in the array function references, along with the arguments that should be passed when the function is called.

    var __functions_to_execute:Array;
    
    function start():void {
        __functions_to_execute = [];
    
        __functions_to_execute.push({func:futile_trace, args:[]});
        __functions_to_execute.push({func:futile_trace, args:['test']});
    
        execute_functions();
    }
    
    function execute_functions():void {
        if(__functions_to_execute.length){
            var obj:Object = __functions_to_execute.shift();
            obj.func.apply(null, obj.args);
        } else  trace("done!");
    }
    
    function futile_trace(_value:String ='rien'):void {
        trace(_value);
        execute_functions();
    }
    
    start();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i've a piece of code that should get the current location and than put
I write a simple piece of code that creates a div and assign it
I've got this really simple piece of code that I thought was the correct
I am currently implementing Quartz.net in a simple application that should execute a piece
I have a simple piece of code: public string GenerateRandomString() { string randomString =
Here is a simple piece of code: import java.io.*; public class Read { public
I've wrote this simple piece of code. And I have a slight problem with
i want to do this simple piece of code work. #include <iostream> #include <windows.h>
i am trying to compile this very simple piece of code class myList {
A common piece of code I use for simple string splitting looks like this:

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.