Constantly hard (coded)

Recently I've been paying a bit more attention to the changes on the Second Life wiki. Not for any special reason, but I've just formed the habit and have even made a point of adding some pages to my watch list. In some small way it's probably also down to the fact that I finally got round to making a user page there.

I quickly noticed that there was a bit of a debate going on regarding many of the LSL pages and the examples on there. A user has recently decided to be helpful and go round and "improve" many of the examples with small edits. It seems that these small edits have, in some cases, resulted in non-working examples. In other cases they've just made the examples less helpful (as seen by some).

My personal view of those edits is that those who have being undoing them are right to do so. But that's beside the point. That's not the purpose of this blog post (which, I'll admit now, isn't going anywhere that'll interest anyone, but I had the urge to waffle about it).

The aspect of all of this that really interested me is something I've wondered about on and off over the last three years of scripting in SL: the special status of channel 0.

Or, more to the point, the way almost none of us call it by its "proper" name: PUBLIC_CHANNEL

Pretty much every scripter's first exposure to the public channel is this script:

From then on I imagine that we all stick with referring to the public channel as a hard-coded 0. Even those of us who have backgrounds as programmers and who (hopefully) use named constants for constant values like this have probably got into the habit of giving that particular channel this special status.

So I was intrigued to see this debate happening on the wiki (snapshot here in case it ever gets removed from the talk page) given I'd been thinking about this very thing on and off for a while: why do I always say 0 when PUBLIC_CHANNEL would be more correct?

In any other language I'd probably use the constant. Actually, in any other language (which allows sensible library design) I'd probably have a wrapper function which I'd use everywhere so the public channel would only get mentioned once. But the point is I'd be motivated by a need for everything to be "correct" and would use the constant somehow, somewhere.

But in LSL I use 0 all the time. I type it without even thinking about it. It's part of my muscle memory. I think about wanting to say something on the public channel; I write llSay( 0, ... ) and don't give it a second thought. It just comes out.

And I think that's one reason why it's a bad idea for someone to go round all the examples on the Wiki and change 0 to PUBLIC_CHANNEL. The reason is that saying 0 when you mean PUBLIC_CHANNEL is idiomatic LSL. It's how the natives speak the language. It's so common to everyone who does speak the language well that it's understood, without question.

So, even though the well-behaved programmer in me screams at me that I should say PUBLIC_CHANNEL, the native speaker of LSL just blurts out 0 and gets on with it. And it can't ever hurt someone learning the language to get used to it.

No comments:

Post a Comment