On Wed, Aug 16, 2000 at 12:31:23PM -0400, John Porter wrote:
> Sorry, this is exactly the argument we get from the C/C++/Java heads,
> who find perl's lack of discrimination between strings and numbers so
> distasteful.  But if we can gloss over the difference between a string
> and a number, we could (not that we should) also gloss over the difference
> between an array and an associative array... or between an array and a
> ref-to-array.  Etc, etc.

You're right, it is pretty much the same argument.

Every language decides on a fundemental set of types to support.
In C/C++/Java, this boils down to scalars, arrays, and objects.
In LISP, you have lists and atoms.  Perl has settled on scalar/array/
hash.  (Well, OK, and typeglob, but that was always a bit odd.)

Each of these languages has good reasons for the choice it made.
I'm not saying that Perl's choices are better than everyone else's;
they are, however, Perl's.  I object to changing them and confusing
everyone without a very good reason indeed.

> > The real problem in the above is context -- when I see @a or %a, I
> > know that it will behave in one fashion in list context, and another
> > in scalar context.  $a, on the other hand, may be trusted to remain
> > the same no matter what the context. 
> 
> Indeed, context is everything.  There is no reason to expect (or demand)
> that $ variables are any more or less "trustworthy" than other variables.
> In fact, with tying, such trust is completely unwarranted.  Not to mention
> overloading.

Are you saying that a tied $a should be able to return a list in list
context?  I would hope not; this rather seriously breaks the principle
of least surprise.

> So, using $ and @ to impose context is a reasonable thing to do.
> Using @ to say "this variable can not be indexed by string" is not.

This is a reasonable statement.  (I was, you realize, arguing against
the removal of $ and @, not against alternate indexing mechanisms for
arrays.)

I'm not certain that I like the idea of string-indexed arrays; I don't
know that I like the thought that $a[5] and $a[05] might suddenly
mean something different.  I could probably be convinced that it isn't
a bad idea, though.

                       - Damien

Reply via email to