@splat provides a more ergonomic way to do what people were mostly using ** for. Features need to actively justify their existence in the language, and nobody piped up with a sufficiently convincing use case for **, so it got removed. Ziglings is designed to teach the language, so the exercises are small examples that don’t necessarily represent real usage. In this case, I think it’s reasonable to just remove this ziglings exercise.
++ is used extensively in real code, so I wouldn’t worry about its removal.
If someone needs this kind of thing, as a one off I would do:
const bit_pattern = blk: {
const pattern = [_]u8{ 1, 0, 0, 1 };
const pattern_2 = pattern ++ pattern;
// repeat as many doublings as are needed.
break :blk pattern ++ pattern_2; // binary of final number
};
and if for some reason your code actually needs to do this a lot, then a userland implementation is reasonable:
fn Repeat(T: type, count: comptime_int) type {
const info = @typeInfo(T).array;
return [count * info.len]info.child;
}
fn repeat(pattern: anytype, count: comptime_int) Repeat(@TypeOf(pattern), count) {
if (count == 1) {
return pattern;
}
const inner_pattern = repeat(pattern, count / 2);
if (count & 1 == 1) {
return inner_pattern ++ inner_pattern ++ pattern;
}
return inner_pattern ++ inner_pattern;
}