rfc:class-like_primitive_types

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
rfc:class-like_primitive_types [2016/12/19 21:56] ajfrfc:class-like_primitive_types [2016/12/19 22:14] ajf
Line 53: Line 53:
   * <php>$x instanceof array</php>   * <php>$x instanceof array</php>
   * <php>$x instanceof object</php>   * <php>$x instanceof object</php>
-  * <php>$x instanceof resource</php> (**FIXME:** should I omit this?)+  * <php>$x instanceof resource</php>
  
 ==== Features not extended to primitives ==== ==== Features not extended to primitives ====
Line 153: Line 153:
 In JavaScript, ''null'' does not have any properties or methods, but ''true'' and ''false'' do. In contrast, Python's ''None'' (its equivalent to null) //does// have properties and methods, albeit only magic methods. In JavaScript, ''null'' does not have any properties or methods, but ''true'' and ''false'' do. In contrast, Python's ''None'' (its equivalent to null) //does// have properties and methods, albeit only magic methods.
  
-This RFC currently chooses to omit null from support by most of these features.+This RFC currently chooses to omit null from the extension of most features of objects to the other types, but excepts <php>instanceof null</php> because it lacks the same potential to create errors.
  
-==== Should resource have a shadow class? ====+==== Should resource be supported? ====
  
 Resource is a legacy type that could be wholly replaced by objects in future. Extending these features to this type would be further entrenching it and contrary to the goal of its eventual removal. Resource is a legacy type that could be wholly replaced by objects in future. Extending these features to this type would be further entrenching it and contrary to the goal of its eventual removal.
 +
 +In particular, <php>instanceof resource</php> could create future backwards-compatibility problems if code uses it to check for values being resources and they later become objects.
  
 ===== Unaffected PHP Functionality ===== ===== Unaffected PHP Functionality =====
Line 170: Line 172:
  
 It also means we can easily introduce new superclasses of our other primitive types. For example, a new <php>\Number</php> type superclassing <php>int</php> and <php>float</php>, or a new <php>\Scalar</php> type superclassing everything except objects and arrays. It also means we can easily introduce new superclasses of our other primitive types. For example, a new <php>\Number</php> type superclassing <php>int</php> and <php>float</php>, or a new <php>\Scalar</php> type superclassing everything except objects and arrays.
 +
 +<php>instanceof</php> could potentially support pseudo-types like <php>callable</php>.
  
 ===== Proposed Voting Choices ===== ===== Proposed Voting Choices =====
rfc/class-like_primitive_types.txt · Last modified: 2017/09/22 13:28 by 127.0.0.1