dmd 2.029 release
Andrei Alexandrescu
SeeWebsiteForEmail at erdani.org
Thu Apr 23 06:43:11 PDT 2009
Steven Schveighoffer wrote:
> On Thu, 23 Apr 2009 09:24:59 -0400, Andrei Alexandrescu
> <SeeWebsiteForEmail at erdani.org> wrote:
>
>> Steven Schveighoffer wrote:
>>> This has to go into object.d and be part of the runtime, where
>>> std.range doesn't exist. There is nothing stopping you from calling:
>>> streamOut(&outputrange.put);
>>> So I'd rather have a sink function.
>>
>> It must be a sink _object_ so it can hold its own state. And it must
>> support put() so it integrates with statically-bound output ranges.
>>
>> interface OutRange
>> {
>> void put(... a number of overloads ...);
>> }
>
> I see now, yes I agree (I think that was don's original request
> anyways). That interface has to go in the runtime, though.
>
> We may not be able to do this using templates... it has to be a virtual
> function in Object to be on-par with toString. This means struct
> interfaces are a requirement if you want to use ranges :(
We're in good shape actually. OutRange as a dynamic interface and an
implicit interface using .put against a struct will work just as well
with templates. (The template doesn't care whether obj.put(x) is a
virtual call or statically-bound call.)
Andrei
More information about the Digitalmars-d-announce
mailing list