Jay Levitt wrote:
That's a violation of common sense. '%!PS-Adobe' isn't going
to change, and therefore 10 won't need changing.
But magic numbers suck.
That would only be true if vendors randomly and unexpectedly changed them. From what I can gather (from Wikipedia and general experience) as formats change vendors may extra add data to the end of the magic number (or create a new one), but always leave the 'base' magic number alone.
Personally, I think you should stop worrying and learn to love the magic number. 
Regards,
Dan
···
On Mon, 08 Oct 2007 16:56:11 -0700, William James wrote:
No, not the magic(5) kind of magic number...
I don't think "%!PS-Adobe"
is changing either. And if it's not changing, then its length will always
be 10.
I'm talking about what wikipedia calls an "unnamed numerical constant". It
took me a few seconds to realize that "10" was the length of "%!PS-Adobe".
Is PS.length (or size, if you prefer) longer to type? Yes. Is it likely
to change? No. Is it more explanatory? Yes. Will it still work when you
copy and paste this code to search for a different magic phrase? Yes.
···
On Tue, 9 Oct 2007 21:19:42 +0900, Daniel Berger wrote:
That would only be true if vendors randomly and unexpectedly changed
them. From what I can gather (from Wikipedia and general experience) as
formats change vendors may extra add data to the end of the magic number
(or create a new one), but always leave the 'base' magic number alone.
Personally, I think you should stop worrying and learn to love the magic
number. 
--
Jay Levitt |
Boston, MA | My character doesn't like it when they
Faster: jay at jay dot fm | cry or shout or hit.
http://www.jay.fm | - Kristoffer
I'm talking about what wikipedia calls an "unnamed numerical constant". It
took me a few seconds to realize that "10" was the length of "%!PS-Adobe".
Is PS.length (or size, if you prefer) longer to type? Yes. Is it likely
to change? No. Is it more explanatory? Yes. Will it still work when you
copy and paste this code to search for a different magic phrase? Yes.
Agreed 100%
From a readability standpoint I'd put it in the same category as
using, say, 90 instead of ?Z.
Or using 1246774599 instead of 'JPEG'.unpack("N").
The number of characters typed (golfing aside) shouldn't even enter
into consideration in cases like these.
Regards,
Bill
···
From: "Jay Levitt" <jay+news@jay.fm>