Enhanced array appending
Leandro Lucarella
llucax at gmail.com
Fri Dec 25 10:44:09 PST 2009
Steven Schveighoffer, el 25 de diciembre a las 06:07 me escribiste:
> > PHP have arrays and hashes combined in one type. You think that's a good
> > idea because arrays and hashes have overlapping features?
>
> I hate to say this, and it has nothing to do with this argument, but I'm
> actually pretty impressed with php's arrays. The rest of php, not so much.
OK, now is clearer than ever that we will never agree on this =)
> They perform like hashes, but are ordered and sortable. I tried to find
> out how they are implemented, but the code is so buried in the zend
> engine that I didn't know where to look.
BTW, they are not "ordered", they preserve the "order of appending" (like
lists or, well, arrays):
$ php -a
Interactive mode enabled
<?
$a = array(1,2);
$a[9] = 9;
$a[5] = 5;
foreach ($a as $k => $v)
printf("%s: %s\n", $k, $v);
0: 1
1: 2
9: 9
5: 5
I think they are a plain hash with a next pointer for the iteration,
I don't think they have much more magic than that.
> > > I think the whole basis of your argument is invalid -- the current
> > > array/slice combination type is easier to use and explain *and* performs
> > > better.
> >
> > I can say exactly the same about you. That's why I said I don't argue
> > anymore about this (grrr! I don't know why I ended up doing it in this
> > thread). This is a matter of taste, you think array/slice combined are
> > easier to use and I don't.
>
> I'd love to see an example where you think this is the case. If it's
> simply a matter of taste, then you have no argument. If that's the
> case, it's just a personal choice, and at that point it's up to Walter.
Exactly. That's what I'm saying about 3 mails ago. I just think it's
easier to think in terms of arrays and slices separately (I know it is for
me). And besides that, you can have simpler implementations, without
making them very tightly coupled with the GC, but you already said too
that for you is not a concern the runtime complexity.
> I just don't see why you think it's easier.
It's just how my mind work. I just like simpler concepts separated than
a type that fit it all a la PHP. Maybe Python has something to do with it
because it works like this. I learned Python after PHP and it seems much
cleaner for me.
--
Leandro Lucarella (AKA luca) http://llucax.com.ar/
----------------------------------------------------------------------
GPG Key: 5F5A8D05 (F8CD F9A7 BF00 5431 4145 104C 949E BFB6 5F5A 8D05)
----------------------------------------------------------------------
Le pedí que me enseñe a usar el mouse
Pero solo quiere hablarme del Bauhaus
Le pregunté si era chorra o rockera
Me dijo "Gertrude Stein era re-tortillera"
Me hizo mucho mal la cumbiera intelectual
More information about the Digitalmars-d
mailing list