Empty value types
Paul Govereau
paul.govereau at oracle.com
Fri Aug 1 17:05:12 UTC 2014
I don't think there is anything wrong with it. I can even think of a use
case: phantom types.
final __ByValue class ReadWrite {}
final __ByValue class ReadOnly {}
final __ByValue class File<T> { ... }
File<ReadWrite> openForWrite(String file) { ... }
File<ReadOnly> openForRead(String file) { ... }
void write(File<ReadWrite> file, ...) { ... }
However, I think we need to add checks to detect construction of empty
value types. I am not sure what to do about methods defined inside of an
empty type? Maybe only static methods are OK?
Paul
On 08/01/2014 12:50 PM, Brian Goetz wrote:
> While an empty value is silly, is there something actually wrong with it?
>
> Sent from my iPhone
>
>> On Aug 1, 2014, at 9:47 AM, Paul Govereau <paul.govereau at oracle.com> wrote:
>>
>> What are we going to do with empty value types?
>>
>> The most sensible thing seems to allow them to be declared but not constructed. e.g.
>>
>> final __ByValue class Void {} // <- ok
>>
>> Void v = __Make Void(); // <- error cannot construct empty type.
>>
>> Paul
More information about the valhalla-dev
mailing list