quettabit
quettabit

Reputation: 2400

What does "prong" mean in the context of Zig language?

From the Zig language documentation, I came across a concept called Inline Switch Prongs. However, there is no explanation for the word prong(s). I was not able to find any explanation from other resources in the internet as well. Can someone explain what it means?

Upvotes: 2

Views: 229

Answers (2)

P.T.
P.T.

Reputation: 25177

I took prong to be derived from the => symbol in Zig's switch, which looks like a fork (the utensil) and forks have prongs.

Upvotes: 1

John Bayko
John Bayko

Reputation: 1099

I think it's an analogy to physical switches, particularly multiple position switches which have an input pin, and several output pins. For example, power in, and two power out pins based on the switch position, or three positions with one being "off" with no connection to either pin.

Usually "prong" is used for a plug, but components like switches can be plugged into circuit boards, so the pins can (rarely, it seems) also be called "prongs".

So the positions of a toggle switch can be matched with prongs. A switch statement (whether zig, C, or some other language) is associated with different case statements, so looks like someone decided to make an analogy. I've never seen this used anywhere else.

Upvotes: 1

Related Questions