30
Hello,

Microsoft has created the new ALAppExtensions with a bunch of functions we constantly use. We often create, in our apps, codeunits with helper functions.
When we use these functions, we have to declare somewhere a codeunit variable everywhere and I am proposing here to be able to declare "static" codeunits.

It would be just a compiler trick but the idea would be that:

- Like dotnet.al, we create a file "staticcodeunits.al" where MyHelperCodeunit is given an alias like MyHelper.
- Anywhere in my app, instead of writing :
var
MyHelper: codeunit MyHelperCodeunit;
begin
MyHelper.DoSomething();
end;

It could be written:
begin
MyHelper.DoSomething();
end;

In our apps, we would be able to use functions like Math.Min, Math.Max, StreamHelper.ToBase64() exactly like Dialog.Message or Text.StrSubstNo.
Category: Development
STATUS DETAILS
New

Comments

N

The static functions on enums give an idea of the syntax that could apply: Codeunit::"MyHelpercodeunit".DoSomething()

Category: Development

N

I would like to extend this idea to static procedures and a static property for the Codeunit itself (to be applied to all contained procedures automatically). This would need some more work to differentiate between static/nonstatic functions, but the "only" requirement is to not call/use instance procedures or instance variables in my opinion.

Category: Development