Personally, I think pass by-value with copy-on-write semantics like
arrays is the sweet spot. Mutability is fine if it is localized.

I think having a no-constructor construction syntax is also a good
idea. I've discussed it with a few people, but don't can't remember if
it's ever been brought up on-list. Basically, the idea is to use a
JSON-like syntax with the type-name in front, and I think it can be
fine to use on regular classes that don't have a constructor too:

    struct Point2d {
      float $x;
      float $y;
    }

    $origin = Point2D { x: 0, y: 0 };

This syntax has no conflicts. We could also add an object literal
syntax for creating ad-hoc stdClass objects like so: `$obj = { x: 1,
y: 1}`. This has an ambiguity, but I believe I have solved the issue
without too much trouble once before.

I think structs, pass by-value with copy-on-write, and brace
construction would go really well together.

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to