m3m0ry / fixedpoint

Decimal fixed point type
Boost Software License 1.0
6 stars 3 forks source link

Verbosity of modules? #2

Closed schveiguy closed 4 years ago

schveiguy commented 4 years ago

fixedpoint.fixeddecimal.FixedDecimal == quite a mouthful.

Typically single module libraries should have at least one package to avoid weird naming issues. But I'd like to see FixedDecimal => Fixed and fixeddecimal => fixed.

I know it conflicts with the old library. I'm not too worried about both being used simultaneously.

m3m0ry commented 4 years ago

Thanks for the feedback. I had the idea, that i also do a fixedbinary. So instead of 10^^ we will have 2^^. It is my first package in dlang, so i am trying things out :)

m3m0ry commented 4 years ago

Hmm i am also confused what the folder structure of a D library should look like. Do you have any tutorials/articles about it? With dub there are multiple possibilities.

schveiguy commented 4 years ago

There's nothing exactly wrong with the structure, it's just that the symbol is really long.

I was hoping you could change the module name of fixeddecimal to fixed, and the type name to Fixed so that the type is: fixedpoint.fixed.Fixed instead.

I had the idea, that i also do a fixedbinary

I'm not seeing the point of such a type. First, floating point is there, and is almost exactly what you would need. Second, I see very little value in it from a UI perspective. People just don't write or read binary numbers much, let alone binary numbers with a fixed point. How would you use such a thing?

In any case, a FixedB or FixedBinary type can live in the same module.

m3m0ry commented 4 years ago

Thanks for the quick response, i hope i have some time tomorrow/on the weekend to make some progress.

I will follow your wishes :)

The binary version is just way quicker, since you don't need to use the multiplication with a factor (10^^n), because you can use a bit shift since it is 2^^n. There is also some naming confusion. I think "fixedpoint" is supposed to be 2^^n, whereas "fixeddecimal" is then for 10^^n.

Somebody on the irc wished for 2^^n version. But you are right. I should first properly finish this thing first, and then i can continue on planning.

schveiguy commented 4 years ago

Another option is to make the package fixed (even though there's already one on code.dlang.org, there is no requirement to have your package name be unique), and then you could have fixed.decimal.FixedDecimal and fixed.binary.FixedBinary. That's a much less repetitive name.

I've been meaning to get to try this out and help make it. Never too early for PRs I think :) I'm currently making do with a really limited FixedDecimal type that I wrote, and I keep running into limitations that I'd rather solve once in a place that everyone can benefit.

m3m0ry commented 4 years ago

I have decided for your first proposal. -> fixedpoint.fixed.Fixed Binary version will be its own package (if i will make one at all).