Only want to say
Andre Pany
andre at s-e-a-p.de
Wed Jan 6 19:06:45 UTC 2021
On Wednesday, 6 January 2021 at 17:56:59 UTC, Jacob Carlborg
wrote:
> On 2021-01-05 14:05, Andre Pany wrote:
>
>> Yes, tuples are a core strength of D, but the syntax is not
>> great. My hope is with the tuple dip we will be able to have a
>> python like syntax:
>>
>> (Python numpy example)
>> arr = numpy.array([('a', 0), ('b', 1)])
>>
>> My gut feeling is, we will be able to compete with numpy if we
>> can provide tuple syntax as python can provide.
>
> I would love to have a better syntax for tuples in D but I'm
> very skeptical that D would be anymore or less suitable to do
> the same things as numpy does only based on getting a better
> tuple syntax.
>
> The above example could be implemented as a variadic template
> in D:
>
> auto arr = array('a', 0, 'b', 1); // less syntax then the
> Python example
>
> Template constraints can be used to make sure there are even
> number of arguments and of the correct types.
Maybe yes, but I am not 100 % sure, as in your example the
information about the dimension count is lost.
In the numpy example you can see there are 2 columns with 2 rows.
Your example is an 1 dimension array.
Here I am not sure how the n-dimendions info can be specified in
a readable way using variadic templates.
King regards
Andre
More information about the Digitalmars-d
mailing list