atifaziz / Boxing

.NET Standard library for boxing any value
https://www.nuget.org/packages/Boxing/
Apache License 2.0
2 stars 0 forks source link

Let box!? #2

Closed dzmitry-lahoda closed 5 years ago

dzmitry-lahoda commented 5 years ago
  1. Box<T> : IBox<T>
  2. readonly struct Box<T>
  3. RefBox https://github.com/scalaz/scalaz-zio/blob/master/core/shared/src/main/scala/scalaz/zio/Ref.scala ? Interlocker? Why class Interlocker? Why not struct?
  4. Ref return:
    
    IRefApply<T>
    {
    ref<T> Invoke()
    }
    public Box(TRefApply<T> valueRef) where TRefApply<T> : IRefApply<T>
    => this.valueRef = valueRef;

public ref T Value = ref valueRef.Invoke();

atifaziz commented 5 years ago

I'm not sure about what you are saying here. Care to clarify/expand?

dzmitry-lahoda commented 5 years ago
  1. There is new design in C#(thanks to all ref suff and Unsafe). In this design it is possible to manage memory manually and pass by ref. But ref cannot be stored without copy. So I want to have index to Memory(or array or circular buffer) stored behind IRefApply call(which is struct) to avoid delegate overhead. Box also struct to avoid overhead and because struct cannot have ref into fields I need ref into manually managed memory. So there should be another ref like Box to state boxing any value. Because I cannot box large structures in sane manner.

  2. I consider Ref.Scala to be a box of some kind. Could Interlocker be named as AtomicBox or like? Could AtomicBox be structure? To have common name pattern? Also it could use some GC allocated object imlementing IRefApply to get ref. Or (if works), as it stores only value it could Unsafe cast it into itself and pass self as ref. So Interlocker maybe can be struct.

  3. Mark as readonly, I guess it is right for designs. Will not hurt? Right?

  4. What is API fox boxes? Any other boxes to have, so interface?

dzmitry-lahoda commented 5 years ago
  1. Box<T< : IBox<out T>
  2. Lazy is : IBox
  3. Interlocker : IBox.
  4. And IRefBox as for ref return.
atifaziz commented 5 years ago

5. Mark as readonly, I guess it is right for designs. Will not hurt? Right?

This is done in ee4c0aeebd9d6db5be828b948cab444ae05db732. However, with respect to the rest, I am completely lost as to what you are asking or suggesting even when I re-read months later. I will close this issue now but happy to re-open if you can provide more clarity. Thanks.