dmd 2.029 release

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Thu Apr 23 07:30:15 PDT 2009


Daniel Keep wrote:
> 
> Andrei Alexandrescu wrote:
>> 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
> 
> "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."
> 
> Note that toString is a virtual method.  You are proposing replacing
> toString with a template.  You cannot have virtual template methods.
> Ergo, "new toString" would be inaccessible without the actual type, and
> certainly not at runtime.

The toStream that I have in mind is virtual and takes an interface of 
type OutRange as outlined above.

Andrei


More information about the Digitalmars-d-announce mailing list