will wray
2018-11-06 20:36:10 UTC
Pointer-to-array declaration syntax is tricky to read and write.
Pointers compose left-to-right while extents are right-to-left.
It'd be easier to read and write if pointers could shift from left to right.
Examples:
T(*)[] -> T[]* T(*a)[]; -> T[]* a;
T(*)[M] -> T[M]* T(*a)[M]; -> T[M]* a;
T(*)[M][N] -> T[M][N]* T(*a)[M][N]; -> T[M][N]* a;
T(*[M])[N] -> T[M]*[N] T(*a[M])[N]; -> T[M]* a[N];
-> T a[M]*[N];
This seems similar to the case with cv qualifiers on left or right of the
type.
Can the grammar cope with this or are there parsing ambiguities?
(I know this has been considered before but don't know the refs - D&E?)
The motivation?
'East pointer' is an alternative to P0332's 'Relaxed Incomplete' proposal
to allow
incomplete bounds to appear in not just the first position of an array type
declaration
P0332 is at a deadend without advocacy as there is concern about
side-effects
https://kokkos.github.io/array_ref/proposals/P0332.html
T[4][][2][1] uses incomplete bound [] to represent a dynamic extent -
it requires a change to the type system and language rules.
T[4]*[2][1] uses pointer * to represent a dynamic extent, requiring
no change to the type system, only declaration syntax.
For now the type can be used with existing syntax T(*[4])[2][1]
or a type alias with 0 representing dynamic extent: mdarray_t<T,4,0,2,1>
Pointers compose left-to-right while extents are right-to-left.
It'd be easier to read and write if pointers could shift from left to right.
Examples:
T(*)[] -> T[]* T(*a)[]; -> T[]* a;
T(*)[M] -> T[M]* T(*a)[M]; -> T[M]* a;
T(*)[M][N] -> T[M][N]* T(*a)[M][N]; -> T[M][N]* a;
T(*[M])[N] -> T[M]*[N] T(*a[M])[N]; -> T[M]* a[N];
-> T a[M]*[N];
This seems similar to the case with cv qualifiers on left or right of the
type.
Can the grammar cope with this or are there parsing ambiguities?
(I know this has been considered before but don't know the refs - D&E?)
The motivation?
'East pointer' is an alternative to P0332's 'Relaxed Incomplete' proposal
to allow
incomplete bounds to appear in not just the first position of an array type
declaration
P0332 is at a deadend without advocacy as there is concern about
side-effects
https://kokkos.github.io/array_ref/proposals/P0332.html
T[4][][2][1] uses incomplete bound [] to represent a dynamic extent -
it requires a change to the type system and language rules.
T[4]*[2][1] uses pointer * to represent a dynamic extent, requiring
no change to the type system, only declaration syntax.
For now the type can be used with existing syntax T(*[4])[2][1]
or a type alias with 0 representing dynamic extent: mdarray_t<T,4,0,2,1>
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+***@isocpp.org.
To post to this group, send email to std-***@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAKjnZWqJjO7kcjUt4YuvJuQM_6ZCmJHc%2Bh5zfhx8y%2Bd8nN5JcA%40mail.gmail.com.
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+***@isocpp.org.
To post to this group, send email to std-***@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAKjnZWqJjO7kcjUt4YuvJuQM_6ZCmJHc%2Bh5zfhx8y%2Bd8nN5JcA%40mail.gmail.com.