|We don't bite newbies here... much|
“A meeting at the Liquor-Vodka Factory”, or… same ARRAY questions again?!!by Mabooka-Mabooka (Sexton)
|on Sep 02, 2005 at 20:14 UTC||Need Help??|
Mabooka-Mabooka has asked for the
wisdom of the Perl Monks concerning the following question:
Dear Patient Monks,
There’s a novel “A meeting at the Liquor-Vodka Factory” (“собрание на ликеро-водочном заводе”) by Russian author M. Zhvanetsky. Workers at a liquor factory are having a meeting. It is structured like this:
The chairman pours himself from a bottle and says: “Today, we are going to listen to our Director of the Transportation Department”.
The Director of the Transportation Department comes forward, pours himself from a bottle and makes some speech.
The chairman pours himself again and says: “Well… Now, let us listen to our Director of the Transportation Department. Please tell us how are things in our transportation”.
The Director of the Transportation Department comes forward again, pours himself, and talks some more.
The chairman: “All right, then. Now, how about our Transportation Department? Where’ s our Director of Transportation? Anybody seen him?”...
And so it goes and goes, until the Chairman says: “Well, the things seem to go right. Except it’s a re-eeeeal pity that today we couldn’t make it to hear our Director of the Transportation Department.”.
... That’s approximately what I feel myself when searching for answers to questions like:
I hear: “Boo!!!”,,, “NOT Again!”, “RTFM!!”, “RTFAQ!!!”…. But please stay with me for another minute, -- I’ll try to prove that the problem still exists.
To make myself clearer, let me ask you three more questions:
I am ready to bet that the ##s are high. And here’s why. Let’s take a look at a) in FAQs here: "How do I find the size of an array?":
It becomes obvious that there are at least 7 answers:-). No one proposes the one and only one best solution, the confusion on whether to add a 1 to the index of the last element persists, and nobody discusses performance implications of casting to a scalar vs. using the last index. But that’s probably OK: an answer CAN be found, it only takes some time….
As for questions b) and c), it’s unfortunately not a case. I mean: neither solution works for me.
... I actually love asking this question during an interview (regardless of the programming language), and see whether the person jumps into writing some sort of a loop or asks: how big is an array? Is it sorted? Is it dynamic?... You know, one could spend hours talking about this stuff.
What is proposed here in FAQs is:
Which means: Arrays are data structures that are always
, and there’re no performance or memory problems whatsoever while dealing with them.
Hmm... guess what: that’s not exactly the set of conditions that ~some~ real-world applications have to deal with.
I assert that:
Besides, there’re integers, floats, doubles, and data structures appearing as elements of arrays sometime…
And on top of all, -- nobody has proposed a subroutine, every recipe's style is not a "production code". (That’s why the code that looks elegant at the 1st glance:
is not really useful: one cannot paste it to a sub to make it work.
So…… Thanks for bearing. I hope I've made a poin. What's missing is:
Well-thought-through and unambiguous answers to these three questions at the very top of the "Array" FAQ list.
THANKS FOR READING!