Generic const - a non-functional view
Dee Girl
deegirl at noreply.com
Thu Jun 26 13:53:58 PDT 2008
Bill Baxter Wrote:
> Dee Girl wrote:
> > Steven Schveighoffer Wrote:
> >
> > You assign $y = $x. Two things could happen, a refcount is done or a full copy is done. You do not know. But you do not care! You care if changing one character in $x changes one character in $y. That never is happen. Which means semantically Perl strings are as good as strings of invariant characters. They never alias mutable data. This is the important thing.
>
> I certainly care if a 100MB string is getting duplicated. It's most
> definitely going to change how I write the algorithm to manipulate that
> string.
Perl uses many strategy. Focus on copy or no copy is missing my point and Walter point.
> "Act like value type" and "are immutable" are two categories which have
> overlap, but they are not identical. Walter keeps saying strings in
> perl are immutable, but Steven's test demonstrates that (at least for
> 100MB strings) they are not immutable, but they do act like value types.
>
> This difference is relevant since Walter has often argued that invariant
> strings are the way to go based on the "fact" that they have been such a
> success in languages like Perl. And the implication is clear there (to
> me any way) that by 'invariant' he means invariant in the sense that D2
> strings are invariant. If he wants to include Perl in his argument he
> should be saying "value type strings" rather than "invariant strings".
> Or he should just stick to using Java as his example. :-)
I am sorry, again missing the point. Walter argument is very good. In Perl may get copy or just reference. In D always get a reference. You can create new copy. So even D has more control than Perl. In Perl you don't control when copy is.
Walter argument was that value-like types are better because no mutable aliasing. Mutable aliasing makes things difficult because for non local dependencies. This why scripting languages so easy to play with strings. D does that in a different way from Perl which is as powerful or even more. I think his point is perfect valid, even when terminology is imprecise this time. And I am happy he does not fall again in his C++ comparison trap where argument becomes childish ^_^. Thank you, Dee Girl
More information about the Digitalmars-d
mailing list