geode-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jacob Barrett <jbarr...@pivotal.io>
Subject Re: [DISCUSS] Using out parameters and its effects on function overload resolution
Date Mon, 02 Oct 2017 19:51:07 GMT
On Mon, Oct 2, 2017 at 12:19 PM David Kimura <dkimura@pivotal.io> wrote:

> The other question though is, could function overload resolution be a valid
> use case for out variables (particularly in PdxReader, for example)?


I am against exceptions to rules unless the exception is more readable. In
this case I don't think the exception to our rule, of using return values
only and no out params, gains anything for single return types that differ.

auto i = input.readInt();
auto b = input.readByte();

Is more expressive and readable than:

int i;
input.read(i);
char b;
input.readByte(b);

Templates could solve the problem, but I am not sure it is more expressive
or easier to read:

auto i = input.read<int32_t>();
auto b = input.read<int16_t>();


It also runs into issues of ballooning specializations for each of the C++
types. See: http://coliru.stacked-crooked.com/a/33ca43ee0ed59a7f
<http://coliru.stacked-crooked.com/a/be6ef60194d4e0db>

I think in this case since the serializer is dealing with our "GemFire
Types" which just happen to be Java types then we should be descriptive in
those terms therefor readInt, readLong, readShort, etc. wins in my book.

-Jake

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message