[foreign-memaccess] [Rev 01] RFR: Add MemorySegment::fill
Chris Hegarty
chegar at openjdk.java.net
Wed May 13 16:40:33 UTC 2020
On Wed, 13 May 2020 16:25:30 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:
>> Nice and simple, but i think there is an open design question here.
>>
>> Notice that the bulk `copy` operation resides on `MemoryAddress`. Fill is a little like a copy, e.g. if expanded later
>> to fill one segment repeatedly with another (if the destination segment is smaller than the source then it's a
>> truncated copy). I think we need to consider grouping bulk operations in the same place.
>
>> I think we need to consider grouping bulk operations in the same place.
>
> I suggested the location to Chris. Since the method operates on segment it felt right to add it on MemorySegment. If we
> add it on MemoryAddress it will look a tad odd IMHO, since it works on segments.
> We could tweak fill to work on MemoryAddress, but that means that the user has to pass an address and a length (which
> is what a segment is).
> Or we could make fill an instance method on segment.
>
> I'm not sure there's one answer that's better than the others here - but I don't have any strong feelings one way or
> another, so I'm open to suggestions.
I agree with the logic of why this method fits better in MemorySegment, rather than MemoryAddress.
Fill seems more like a "utility", rather than an operation on the segment itself, so I marginally favour a static
method.
-------------
PR: https://git.openjdk.java.net/panama-foreign/pull/161
More information about the panama-dev
mailing list