On 3 February 2015 06:59:06 GMT, Alexander Lisachenko <lisachenko...@gmail.com> 
wrote:
>I want to add a link here to the Java article about Value Types, this
>information is quite interesting:
>http://cr.openjdk.java.net/~jrose/values/values-0.html
>
>Probably, immutable value objects will be soon in Java world according
>to
>this information:
>
>
>> Conclusion
>>
>> Along with the questions, we believe we have enough answers and
>insights
>> to begin prototyping value types, and verifying our thesis. That is,
>we
>> think it quite likely that a restricted class-like type can be made
>to look
>> enough like a primitive to be worth adding to the language and VM.

Ooh, that does look like an interesting read. I'm particularly intrigued by 
their notion of "custom basic types". I'm beginning to dream about such types 
being a way of introducing various features:

- immutability and/or COW; if they can't have normal objects as members, then 
the deep cloning/immutability problem basically goes away
- operator overloading (without allowing it on normal objects); perhaps further 
limited to cases where both operands are of the same type (e.g. money + money) 
to avoid complicated dispatch algorithms
- range and domain types as sub-classes of scalars, with some kind of cast 
declaration; dare I say it, this could be more useful than scalar type hinting, 
since you're able to check arbitrary limits
- "scalar methods" / autoboxing; standard PHP could include basic methods (e.g. 
those array_* and str_* functions which have a natural "subject"), and you 
could add more by casting to a subtype, with much less overhead than an object 
wrapper

Maybe if we keep experimenting, we can come up with something really awesome 
for PHP 8...
-- 
Rowan Collins
[IMSoP]


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

Reply via email to