Leopold Toetsch wrote:
> Fine. But how do we know, which version we could take. Please read again
> Peter's example. It depends on the semantics of Sx register usage all
> over the program IMHO.

In an attempt to clarify the positions here, let us start with a shorter
example:
  set S0, "zero"
  set S1, "one"
  set S0, S1

The first line will create a new string header, which will COW-reference
the constant string data "zero", and store the address of that header
in register S0.
The second line creates another string header, COWing to "one",
and stores its address in register S1.
The third line could do any of the following:
   a) Create a new string header, COW-referencing string "one",
      and store that new address in register S0
   b) Re-use the existing string header created in line 1, changing
      it to point to string "one"; the register does not change
   c) Store the address of the string header created in line 2 into
      string register S0; no headers are affected in any way
The current implementation is (c).
Does anybody believe this should be different?

An extended version of my previous example follows, as it points
out some more inconsistent behaviour.
--
Peter Gibbs
EmKel Systems

  set S0, "test"
  set S1, S0
  set S2, "another"
  substr S0, S2, 1, 3
  print S1
  print "\n"

  set S0, "test"
  new P1, .PerlString
  set P1, S0
  set S2, "another"
  substr S0, S2, 1, 3
  print P1
  print "\n"

  set S0, "test"
  new P1, .PerlArray
  set P1[0], S0
  set S2, "another"
  substr S0, S2, 1, 3
  set S3, P1[0]
  print S3
  print "\n"

  set S0, "test"
  new P1, .PerlHash
  set P1["a"], S0
  set S2, "another"
  substr S0, S2, 1, 3
  set S3, P1["a"]
  print S3
  print "\n"

  end


Reply via email to