Funarg problem

In some ways, the issue is how to deal with functions – traditionally the thought was to think of functions as stack based but how do we handle below situation:

 

function a{

var x = 20;

function b{ x = 10;}

}

 

Note that x hasn’t been passed as an argument.

Now, if functions are implemented as stacks , how do you push / pop the function state.

Solution is to use heap but it’s more expensive .



Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s