[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: data type for nargin
From: |
Rik |
Subject: |
Re: data type for nargin |
Date: |
Mon, 7 Dec 2015 08:26:33 -0800 |
On 12/07/2015 07:34 AM, Olaf Till wrote:
> On Mon, Dec 07, 2015 at 08:55:12AM -0500, John W. Eaton wrote:
>> On 12/06/2015 11:07 PM, Rik wrote:
>> ...
>>> In browsing through the code I see there has been some confusion as to what
>>> data type to use for nargin. The two most common templates are
>>>
>>> --- nargin templates ---
>>> int nargin = args.length ();
>>> octave_idx_type nargin = args.length ();
>>> --- End Code ---
>>>
>>> I propose standardizing on the first since it is shorter.
>> Using int should be OK as I don't think it is reasonable for it to ever be
>> larger than 2^31. At least I hope no one ever needs that. Can you imagine
>> a case where that could be true?
> Maybe something like the following:
>
> horzcat (large_cell_array{:})
>
> Indeed a similar line is currently in scripts/general/cell2mat.m. And
> if someone wants to handle matrices so large that octave_idx_type is
> needed, it is probably equally legitimate to handle cell-arrays
> (containing numbers) of that size.
>
> But why not deciding for each function separately if octave_idx_type
> could be needed ...
Another point to consider is that unless you are especially compiling with
64-bit indexing, the octave_idx_type is defined to be int already. For
more than 95% of the builds we are just using a longer word in place of a
shorter word.
--Rik