ziglang / zig

General-purpose programming language and toolchain for maintaining robust, optimal, and reusable software.
https://ziglang.org
MIT License
33.71k stars 2.47k forks source link

pitch: rename the "Child" types #2902

Open distractedlambda opened 5 years ago

distractedlambda commented 5 years ago

I can understand the origin of the name choice Child, but I dislike it for a couple of reasons:

I therefore propose that the Child types get renamed to some set of new (and unique) names. I don't think it matters so much what the exact names are, but rather that they are unique, and that they have something to do with what the type represents. A few suggestions:

marler8997 commented 5 years ago

Note that if they all use the same name, then generic code can be simpler in some cases:

fn foo(a: var) @typeOf(a).Child { ... }

How would you write this with your proposal?

Also, If we had a different name for each type of array, wouldn't it be harder to remember the specific name for each one? Child is kind of an odd name, I wouldn't mind changing it but I'm not seeing the benefit of creating a unique name for each type of array.

andrewrk commented 5 years ago

Child is actually deprecated, to be future proof use @typeInfo. See also std.meta.Child.

distractedlambda commented 5 years ago

@marler8997 I can see your point, although if the plan is to switch to implementing these sorts of "type traits" in user code atop @typeInfo, then we could reasonably have both at the same time. We could all have Child functions and Element functions and Unwrapped functions and whatever else suited our particular fancies.

marler8997 commented 5 years ago

Yes, using @typeInfo allows for both.

andrewrk commented 4 years ago

This affects, e.g. https://github.com/ziglang/zig/blob/702398dd0e2188ad03b3c4760c08ea673573489e/lib/std/builtin.zig#L188

Note also the naming convention of types should be respected.

ghost commented 3 years ago
  • For pointers, Pointee, Target, or Dereferenced, etc.

  • For optionals, Unwrapped, Inner, Value, NonNull, etc.

  • For arrays, Element, Item, etc.

  • For vectors, Element, Component, Scalar, etc.

You know, Element would work for all of these. Rly maks u thonkum

data-man commented 3 years ago

What's problem? std.meta.Elem is already exists.