On Wednesday, 2 September 2015 at 04:04:54 UTC, Sergei Degtiarev wrote:
I seems a little bit too easy to to shoot yourself in the foot.

Yes, cast is a little not fool-proof in this scenario.

On Thursday, 3 September 2015 at 13:28:54 UTC, Sergei Degtiarev wrote:
Agree, however, memory obtained with mmap(..., PROT_READ, ..); is essentially read-only and any attempt to write to it will cause immediate crash with segmentation violation. It would be very desirable in this case to return something that could be cast to immutable(type)[] but not type[].

If you can't write to it doesn't mean it won't change. Use const for memory that you can't write to.

On Thursday, 3 September 2015 at 16:05:33 UTC, Sergei Degtiarev wrote:
Absolutely, instead of returning raw void[] and allow user to cast it, std.mmfile should implement template function to return desired type.

Well, interpretation of data can be arbitrarily complex, I'd suggest that the raw data should be passed to your specific parser, that will do the right thing and provide data in expected format.

Reply via email to