More D newb questions.

Janice Caron caron800 at googlemail.com
Wed May 7 01:06:54 PDT 2008


2008/5/7 Me Here <p9e883002 at sneakemail.com>:
>  So then, <i>if</i> a ~ b worked

Sorry to be pedantic, but a ~ b does work. It does exactly what it's
defined to do. What you mean is, if a ~ b exhibited the bizarre and
unexpected behavior suggested in this thread.

>, then
>         f( MyArray( a ~ b ) );
>
>  would work? (Just a question:)

Not by default, but it could be /made/ to work. Assuming MyArray was a
struct, then the expression MyArray(n) would create a MyArray on the
stack and assign its first and only element with n. If that turns out
not to possible, it's an error. To make it work, you'd have to
overload static opCall(char[]) for MyArray. Of course, you might want
to do that anyway - but even so, there'd still be a wasteful temporary
allocated on the heap.



More information about the Digitalmars-d mailing list