DMD 1.022 and 2.005 releases
Bill Baxter
dnewsgroup at billbaxter.com
Wed Oct 10 09:18:59 PDT 2007
BLS wrote:
> Regan Heath schrieb:
>> BLS wrote:
>>> Bill Baxter schrieb:
>>>> BLS wrote:
>>>>> 0ffh schrieb:
>>>>>
>>>>>> With the help of explicit pointers and dereferencing, I can see no
>>>>>> trouble
>>>>>> except you'll need a lot of stars... :)
>>>>>>
>>>>>> Regards, Frank
>>>>>>
>>>>>> ps. btw. plain C doesn't have &refs either
>>>>>
>>>>> Would be nice if you are willing to offer an example.
>>>>> It could also be used as example on :
>>>>> http://www.prowiki.org/wiki4d/wiki.cgi?PortingFromCxx
>>>>> thanks in advance, Bjoern
>>>>
>>>> He just means have the function return Foo* instead of Foo&. And
>>>> then use (*foo) everwhere instead of plain foo on calling side.
>>>> That's pretty much the only reasonable solution I can see.
>>>>
>>>> --bb
>>> Thanks for clarification Bill. Wonder why Frank wrote : "except
>>> you'll need a lot of * " ?
>>> Bjoern
>>>
>>
>> I assumed he meant something like:
>>
>> -- C++ --
>> void foo(int &i)
>> {
>> ..lots of uses of 'i' eg "i = 5"..
>> }
>>
>> -- D --
>> void foo(int *i)
>> {
>> ..lots of uses of '*i' eg "*i = 5"..
>> }
>>
>
> I think :
> void foo(ref int i){}
> will do the Job in D
Except if you try to call foo(42).
-- ERROR 42 is not an lvalue
(Which is another reason why they're often made const in C++ -- you can
pass a literal or temporary to a const T&, but not to a T&.
--bb
More information about the Digitalmars-d-announce
mailing list