rename @field to @member for clarity #32029
Labels
No labels
abi/f32
abi/ilp32
abi/sf
accepted
arch/21k
arch/6502
arch/aarch64
arch/alpha
arch/amdgcn
arch/arc
arch/arc32
arch/arc64
arch/arm
arch/avr
arch/bfin
arch/bpf
arch/colossus
arch/cris
arch/csky
arch/dlx
arch/epiphany
arch/fr30
arch/frv
arch/hexagon
arch/hppa
arch/hppa64
arch/ia64
arch/kalimba
arch/kvx
arch/lanai
arch/lm32
arch/loongarch32
arch/loongarch64
arch/m32r
arch/m68k
arch/m88k
arch/mcore
arch/microblaze
arch/mips
arch/mips64
arch/mmix
arch/moxie
arch/mrisc32
arch/msp430
arch/nds32
arch/ns32k
arch/nvptx
arch/or1k
arch/powerpc
arch/powerpc64
arch/propeller
arch/riscv32
arch/riscv64
arch/rl78
arch/rx
arch/s390x
arch/sh
arch/sparc
arch/sparc64
arch/spirv
arch/spu
arch/tricore
arch/v850
arch/vax
arch/vc4
arch/ve
arch/wasm
arch/x86
arch/x86_64
arch/xcore
arch/xtensa
autodoc
backend/c
backend/llvm
backend/self-hosted
binutils
breaking
build system
debug info
docs
error message
frontend
fuzzing
incremental
lib/c
lib/compiler-rt
lib/cxx
lib/std
lib/tsan
lib/ubsan-rt
lib/unwind
linking
miscompilation
os/android
os/dragonfly
os/driverkit
os/emscripten
os/freebsd
os/fuchsia
os/haiku
os/hurd
os/illumos
os/ios
os/linux
os/maccatalyst
os/macos
os/managarm
os/netbsd
os/ohos
os/openbsd
os/plan9
os/redox
os/rtems
os/serenity
os/tvos
os/uefi
os/visionos
os/wasi
os/watchos
os/windows
proposal
release notes
testing
zig cc
zig fmt
zig reduce
bounty
bug
contributor-friendly
downstream
enhancement
infra
optimization
question
regression
upstream
use case
No assignees
9 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
ziglang/zig#32029
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Migrated (and mutated) from https://github.com/ziglang/zig/issues/3839
@fieldisa.bsyntax, it's not specifically for fields. For consistency, rename the builtin to@member.Also for consistency, rename our "field access syntax" grammar to "member access syntax".
This proposal isn't dependent on but is closely connected to introduce
@FieldEnumand use it for the operand type of builtins that accept a field name #23618, which proposes that@fieldshould be changed to take a@FieldEnum(T)instead of[]const u8. One of the comments points out:If
@fieldis changed to@member(instead of being split out into@fieldand@decl, as suggested by the original #3839), and if the@FieldEnumproposal were to be accepted and pursued, then a corresponding@DeclEnumbuiltin will be necessary to not lose the ability to access decls, and the@memberbuiltin would need to behave rougly like:@FieldType->@Membershould be included in thisI believe this examples shows a deeper problem with
@fieldor@member: It can be used to access fields and declarations alike. I would rather prefer having 2 builtins: one for fields and one for members. It would disambiguate the two. Of course their could be breakage when one wants to access both field and declarations, but I can figure out a case where one would want that.no, imo it only highlights that
@membershould stay using stringsDoes this proposal include the rename of
@fieldParentPtr?Maybe I would rename it
@parentPtrFromMemberPtr?@gschwind I don't think so. The current
@fieldserves two functions: accessing struct fields and accessing namespace declarations. This is the reason it needs to be renamed.@fieldParentPtris clearly performing its function; it only applies to fields.@npc1054657282 ok look good
Related: #30107
I would like to work on this, but I need to update
zig1.wasmright? I cannot do that because I have a 4GB machine. Would a series of patches that change uses of@fieldand@FieldTypeto@memberand@Memberstill be useful?Edit: Now I have a 16GB machine.
Is it possible to rename
@fieldto@accessinstead?@access(T, "b")would read "through T access an element namedb".Not all usage of
a.bcan be seen as a member access.left aside the
a.b(c)syntax can mean call a function stored ina's fieldbwithcas argument OR call a function associated with the type ofawithaandcas arguments, this is can be only decided after sema. IMO only the first one can/should be replicated with@access(a, "b")(c).If in
a.b,bshould read "member ofa", what is a "member"?"Something part of some other thing"? : fields for object instances, decl for type/namespace.
Or "Something closely associated with some other thing"? :
arr.len, islenpart of the type or the instance ? why can we access it through the instance?Or better "Something that can be ACCESSED through some other thing"! : can imply constness propagation, implicit pointer dereference ...
Just like semantic considerations are leading
@field->@member(#35323 (comment)) others will probably plague the new@member(#35826). We can decide later what can be accessed through what or not. It seems MORE FUTURE PROOF to name it@accesswhich make explicit that we want to access something through another thing, the accessed things may be a field, a declaration or else ...