I don't know for what this restriction is intended, but in GLSL shaders, you may use non-constant as an index for these types, allowing such constructions: