Internal methods

There are often times that we write a method within a method to reduce the amount of code we have to write and often to allow for recursive code. This would look something like:

void program()
{
int    i;
void internal()
{
some code;
}
code;
}

The code block would call the internal method, and for recursive programming, the internal method would often call itself.

While this coding method works fine, and the use of recursive programming is very efficient, it does cause warning messages when compiling in DAX. The reason for this is not the X++ compile but the CIL compile. Since we want code to run in CIL, as it is more efficient, we want to ensure the code will compile as cleanly as possible.

To achieve the most efficient code we need to eliminate the use of this kind of coding, and create sub methods within the classes we are developing. These sub method will still allow for recursive programming, but will eliminate the warning messages about ‘Recursive local functions are not supported in CIL from X++. Consider removing them’

There are a number of examples found within standard DAX that use the internal method, all of which can be easily fixed by creating sub methods.

Advertisements

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s