This is what Bonjour (nee Rendezvous aka Zeroconf) does in life, and Windows machines do the same thing. Hostnames are not private otherwise why would you need a name in the first place?
This brings up an interesting question; since by default on iOS the hostname is based on the user's name, what will happen when two people with the same hostname (e.g., john-smith-iphone.local) both connect to a public WiFi network? Is there automatic conflict resolution?
From what I can see on my Macbook Pro, yes, there is. One of the hostnames (the one that connected after the original) is automatically changed (in my experience it either appends a number to your current hostname or it completely changes your hostname, to something based on the network).
PS: I'm guessing here that the iOS behaviour when it comes to hostnames is similar to Lion's.
To confirm it kicked in, open Applications -> Utilities -> Terminal and type 'hostname'. This is what anyone else on the same network sees you as. You'll also see your machine on other Macs in Finder under the 'Devices' sidebar.
(the whole story surrounding hostnames is moderately more complicated than this, but the Sharing panel on System Preferences is what informs the Bonjour local network name and that's good enough for 95% of user-facing things)
Edit: I misread, thought you were talking about OSX.