Algorithms should be free from rich types

Max Samukha maxsamukha at gmail.com
Wed Jun 28 09:25:16 UTC 2023


On Tuesday, 27 June 2023 at 21:53:59 UTC, Ali Çehreli wrote:
> My mind is not fully clear on this topic yet but some related 
> things have been brewing in me for years.
>
> Unfortunately, the poor little algorithm is not free to be 
> used: It is written to work with a custom type of that library; 
> let's call it MySlice, which is produced by MyMemoryMappedFile, 
> which is produced by MyFile, which is initialized only by types 
> like MyFilePath. (I may have gotten the relationships wrong 
> there.)
>
> But my data is already in a memory area that I own! How can I 
> call that algorithm? Should I write it to a file first and then 
> use those rich types to access the algorithm? That should not 
> be necessary...

That's some poorly designed library (Phobos?). A decently 
designed one would at least allow you to construct a MySlice 
instance from a (pointer, length) pair.




More information about the Digitalmars-d mailing list