primitive vector types

Bill Baxter wbaxter at gmail.com
Sat Feb 21 12:54:22 PST 2009


On Sun, Feb 22, 2009 at 5:11 AM, Andrei Alexandrescu
<SeeWebsiteForEmail at erdani.org> wrote:
> Bill Baxter wrote:
>>
>> On Sun, Feb 22, 2009 at 4:00 AM, Andrei Alexandrescu
>> <SeeWebsiteForEmail at erdani.org> wrote:
>>>
>>> Jarrett Billingsley wrote:
>>>>
>>>> On Sat, Feb 21, 2009 at 12:32 PM, Andrei Alexandrescu
>>>> <SeeWebsiteForEmail at erdani.org> wrote:
>>>>
>>>>> Yah. Walter agrees that that's the right thing to do. The only thing
>>>>> that
>>>>> worries us is passing by-value large statically-sized vectors to
>>>>> template
>>>>> functions. But then gaming code wants to do exactly that.
>>
>> I don't follow you.  Wouldn't they rather pass such huge chunks of
>> data by reference?
>>
>> --bb
>
> What I'm saying (sorry for being unclear) is:
>
> 1. If we choose T[N] as a value type, the downside is that people may pass
> large arrays by values to e.g. template functions.
>
> 2. The upside is that gaming programmers DO want to pass short arrays of
> type T[N] by value.
>
> The conundrum is that a type system can't say that T[N] has some semantics
> for N <= Nmax and some other semantics for N > Nmax. So we need to pick one,
> and probably picking the value semantics is the right thing to do.
>

Ok.  And for large static arrays you can still explicitly use ref, right?
That's what I was confused about -- sounded like you were saying ref
wouldn't even be possible.  I don't think there are many cases where
you don't know in advance if the static array you are expecting is
huge or not.  And you can always get creative with static if() in the
cases where you don't.

--bb



More information about the Digitalmars-d mailing list