Type | Wish | Status | reviewed | Date | 16-Jan-2009 23:08 |
---|---|---|---|---|---|
Version | alpha 31 | Category | n/a | Submitted by | BrianH |
Platform | All | Severity | minor | Priority | normal |
Summary | AS type! action, with AS-* wrapper mezzanines |
---|---|
Description |
AS would have the same parameters as TO and behave like this: - AS value1 value2, where the types of the values are the same: Return value2 reference. - AS value1 value2, where the types of the values are different: Same as TO. - AS type1 value2, where type1 = type? value2: Return value2 reference. - AS type1 value2, where type1 != type? value2: Same as TO. This would be used widely for quickie type conversions only where necessary, and no copy if not. This would not be like the R2 type aliasing functions AS-STRING and AS-BINARY: no shared data if there is any change in datatype. A useful variant from the TO behavior would be for block types to wrap strings instead of converting them; this kind of type-specific behavior would be an advantage to implementing AS as an action. There would be autogenerated AS-* mezzanine wrappers like TO-*. |
Example code |
Equivalent REBOL implementation: as: func [ "Converts to a specified datatype if different, else returns the original." type [any-type!] "The datatype or example value" spec [any-type!] "The attributes of the new value" ] [ unless datatype? :type [type: type? :type] either type = type? :spec [:spec] [to type :spec] ] |
Assigned to | n/a | Fixed in | - | Last Update | 30-May-2009 17:20 |
---|
Comments | |
---|---|
(0000890)
BrianH 30-May-2009 17:20 |
This needs to be considered or rejected before the utype! spec is finalized, and might affect the host interface if the number and layout of actions affects that. |
Date | User | Field | Action | Change |
---|---|---|---|---|
30-May-2009 17:20 | BrianH | Comment : 0000890 | Added | - |
30-May-2009 17:18 | BrianH | Comment : 0000291 | Removed | - |
27-Apr-2009 01:54 | BrianH | Status | Modified | waiting => reviewed |
12-Feb-2009 22:15 | BrianH | Severity | Modified | not a bug => minor |
20-Jan-2009 05:11 | BrianH | Status | Modified | reviewed => waiting |
20-Jan-2009 04:39 | BrianH | Comment : 0000291 | Modified | - |
19-Jan-2009 22:18 | BrianH | Comment : 0000291 | Added | - |
19-Jan-2009 22:15 | BrianH | Severity | Modified | minor => not a bug |
19-Jan-2009 22:15 | BrianH | Status | Modified | submitted => reviewed |
16-Jan-2009 23:20 | BrianH | Description | Modified | - |
16-Jan-2009 23:20 | BrianH | Code | Modified | - |
16-Jan-2009 23:08 | BrianH | Ticket | Added | - |