Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

Why is FilePath an aggregate, instead of free functions?

aggregate Free functions
0
Posted

Why is FilePath an aggregate, instead of free functions?

0

• A: Under the covers, file-system functions typically interact with the O/S using a C API. Much of that API operates with a null-terminated string, requiring a conversion from D to C text. A free-function design is somewhat encouraged to invoke heap activity when interfacing with these API, by appending a null on each invocation. FilePath uses encapsulation to avoid this overhead by acting as a specialized text-editor, and employing a little bit of buffering. The heap activity is visible when using FilePath, rather than being hidden under the covers, and it is generally limited to O(1) rather than the O(n) of a per-invocation model. A similar situation exists where editing or concatenation of file-path components takes place.

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.

Experts123