Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "EDT:EGL Language Primitive Type Conversions"

Line 7: Line 7:
 
To see if there's a conversion from one type to another, find the cell in "from" type's row and the "to" type's column.  
 
To see if there's a conversion from one type to another, find the cell in "from" type's row and the "to" type's column.  
  
<span style="background: #ffa500">This matrix might contain differences from RBD.</span>  
+
<span style="background: none repeat scroll 0% 0% rgb(255, 165, 0);">This matrix might contain differences from RBD.</span>  
  
{| border="1" cellspacing="1" cellpadding="1"
+
{| cellspacing="1" cellpadding="1" border="1"
 
|-
 
|-
| <br>
+
| <br>  
| bgcolor="#cccccc" | bigint<br>
+
| bgcolor="#cccccc" | bigint<br>  
| bgcolor="#cccccc" | boolean<br>
+
| bgcolor="#cccccc" | boolean<br>  
| bgcolor="#cccccc" | bytes<br>
+
| bgcolor="#cccccc" | bytes<br>  
| bgcolor="#cccccc" | date<br>
+
| bgcolor="#cccccc" | date<br>  
| bgcolor="#cccccc" | decimal<br>
+
| bgcolor="#cccccc" | decimal<br>  
| bgcolor="#cccccc" | float<br>
+
| bgcolor="#cccccc" | float<br>  
| bgcolor="#cccccc" | &nbsp; int&nbsp; <br>
+
| bgcolor="#cccccc" | &nbsp; int&nbsp; <br>  
| bgcolor="#cccccc" | number<br>
+
| bgcolor="#cccccc" | number<br>  
| bgcolor="#cccccc" | smallfloat<br>
+
| bgcolor="#cccccc" | smallfloat<br>  
| bgcolor="#cccccc" | smallint<br>
+
| bgcolor="#cccccc" | smallint<br>  
| bgcolor="#cccccc" | string<br>
+
| bgcolor="#cccccc" | string<br>  
 
| bgcolor="#cccccc" | timestamp<br>
 
| bgcolor="#cccccc" | timestamp<br>
 
|-
 
|-
| bgcolor="#cccccc" | bigint<br>
+
| bgcolor="#cccccc" | bigint<br>  
| align="center" | a<br>
+
| align="center" | a<br>  
| align="center" | <br>
+
| align="center" | <br>  
| align="center" | g<br>
+
| align="center" | g<br>  
| align="center" | <br>
+
| align="center" | <br>  
| align="center" | f<br>
+
| align="center" | f<br>  
| align="center" | f<br>
+
| align="center" | f<br>  
| align="center" | f<br>
+
| align="center" | f<br>  
| align="center" | f<br>
+
| align="center" | f<br>  
| align="center" | f<br>
+
| align="center" | f<br>  
| align="center" | f<br>
+
| align="center" | f<br>  
| align="center" | d<br>
+
| align="center" | d<br>  
 
| align="center" | <br>
 
| align="center" | <br>
 
|-
 
|-
| bgcolor="#cccccc" | boolean<br>
+
| bgcolor="#cccccc" | boolean<br>  
| align="center" | <br>
+
| align="center" | <br>  
| align="center" | a<br>
+
| align="center" | a<br>  
| align="center" | <br>
+
| align="center" | <br>  
| align="center" | <br>
+
| align="center" | <br>  
| align="center" | <br>
+
| align="center" | <br>  
| align="center" | <br>
+
| align="center" | <br>  
| align="center" | <br>
+
| align="center" | <br>  
| align="center" | <br>
+
| align="center" | <br>  
| align="center" | <br>
+
| align="center" | <br>  
| align="center" | <br>
+
| align="center" | <br>  
| align="center" | b<br>
+
| align="center" | b<br>  
 
| align="center" | <br>
 
| align="center" | <br>
 
|-
 
|-
| bgcolor="#cccccc" | bytes<br>
+
| bgcolor="#cccccc" | bytes<br>  
| align="center" | h<br>
+
| align="center" | h<br>  
| align="center" | <br>
+
| align="center" | <br>  
| align="center" | j<br>
+
| align="center" | j<br>  
| align="center" | <br>
+
| align="center" | <br>  
| align="center" | i<br>
+
| align="center" | i<br>  
| align="center" | h<br>
+
| align="center" | h<br>  
| align="center" | h<br>
+
| align="center" | h<br>  
| align="center" | <br>
+
| align="center" | <br>  
| align="center" | h<br>
+
| align="center" | h<br>  
| align="center" | h<br>
+
| align="center" | h<br>  
| align="center" | <br>
+
| align="center" | <br>  
 
| align="center" | <br>
 
| align="center" | <br>
 
|-
 
|-
| bgcolor="#cccccc" | date<br>
+
| bgcolor="#cccccc" | date<br>  
| align="center" | <br>
+
| align="center" | <br>  
| align="center" | <br>
+
| align="center" | <br>  
| align="center" | <br>
+
| align="center" | <br>  
| align="center" | a<br>
+
| align="center" | a<br>  
| align="center" | <br>
+
| align="center" | <br>  
| align="center" | <br>
+
| align="center" | <br>  
| align="center" | <br>
+
| align="center" | <br>  
| align="center" | <br>
+
| align="center" | <br>  
| align="center" | <br>
+
| align="center" | <br>  
| align="center" | <br>
+
| align="center" | <br>  
| align="center" | k<br>
+
| align="center" | k<br>  
 
| align="center" | <br>
 
| align="center" | <br>
 
|-
 
|-
| bgcolor="#cccccc" | decimal<br>
+
| bgcolor="#cccccc" | decimal<br>  
| align="center" | f<br>
+
| align="center" | f<br>  
| align="center" | <br>
+
| align="center" | <br>  
| align="center" | g<br>
+
| align="center" | g<br>  
| align="center" | <br>
+
| align="center" | <br>  
| align="center" | j<br>
+
| align="center" | j<br>  
| align="center" | f<br>
+
| align="center" | f<br>  
| align="center" | f<br>
+
| align="center" | f<br>  
| align="center" | f<br>
+
| align="center" | f<br>  
| align="center" | f<br>
+
| align="center" | f<br>  
| align="center" | f<br>
+
| align="center" | f<br>  
| align="center" | d<br>
+
| align="center" | d<br>  
 
| align="center" | <br>
 
| align="center" | <br>
 
|-
 
|-
| bgcolor="#cccccc" | float<br>
+
| bgcolor="#cccccc" | float<br>  
| align="center" | f<br>
+
| align="center" | f<br>  
| align="center" | <br>
+
| align="center" | <br>  
| align="center" | g<br>
+
| align="center" | g<br>  
| align="center" | <br>
+
| align="center" | <br>  
| align="center" | f<br>
+
| align="center" | f<br>  
| align="center" | a<br>
+
| align="center" | a<br>  
| align="center" | f<br>
+
| align="center" | f<br>  
| align="center" | f<br>
+
| align="center" | f<br>  
| align="center" | f<br>
+
| align="center" | f<br>  
| align="center" | f<br>
+
| align="center" | f<br>  
| align="center" | d<br>
+
| align="center" | d<br>  
 
| align="center" | <br>
 
| align="center" | <br>
 
|-
 
|-
| bgcolor="#cccccc" | int<br>
+
| bgcolor="#cccccc" | int<br>  
| align="center" | f<br>
+
| align="center" | f<br>  
| align="center" | <br>
+
| align="center" | <br>  
| align="center" | g<br>
+
| align="center" | g<br>  
| align="center" | <br>
+
| align="center" | <br>  
| align="center" | f<br>
+
| align="center" | f<br>  
| align="center" | f<br>
+
| align="center" | f<br>  
| align="center" | a<br>
+
| align="center" | a<br>  
| align="center" | f<br>
+
| align="center" | f<br>  
| align="center" | f<br>
+
| align="center" | f<br>  
| align="center" | f<br>
+
| align="center" | f<br>  
| align="center" | d<br>
+
| align="center" | d<br>  
 
| align="center" | <br>
 
| align="center" | <br>
 
|-
 
|-
| bgcolor="#cccccc" | number<br>
+
| bgcolor="#cccccc" | number<br>  
| align="center" | f<br>
+
| align="center" | f<br>  
| align="center" | <br>
+
| align="center" | <br>  
| align="center" | g<br>
+
| align="center" | g<br>  
| align="center" | <br>
+
| align="center" | <br>  
| align="center" | f<br>
+
| align="center" | f<br>  
| align="center" | f<br>
+
| align="center" | f<br>  
| align="center" | f<br>
+
| align="center" | f<br>  
| align="center" | a<br>
+
| align="center" | a<br>  
| align="center" | f<br>
+
| align="center" | f<br>  
| align="center" | f<br>
+
| align="center" | f<br>  
| align="center" | d<br>
+
| align="center" | d<br>  
 
| align="center" | <br>
 
| align="center" | <br>
 
|-
 
|-
| bgcolor="#cccccc" | smallfloat<br>
+
| bgcolor="#cccccc" | smallfloat<br>  
| align="center" | f<br>
+
| align="center" | f<br>  
| align="center" | <br>
+
| align="center" | <br>  
| align="center" | g<br>
+
| align="center" | g<br>  
| align="center" | <br>
+
| align="center" | <br>  
| align="center" | f<br>
+
| align="center" | f<br>  
| align="center" | f<br>
+
| align="center" | f<br>  
| align="center" | f<br>
+
| align="center" | f<br>  
| align="center" | f<br>
+
| align="center" | f<br>  
| align="center" | a<br>
+
| align="center" | a<br>  
| align="center" | f<br>
+
| align="center" | f<br>  
| align="center" | d<br>
+
| align="center" | d<br>  
 
| align="center" | <br>
 
| align="center" | <br>
 
|-
 
|-
| bgcolor="#cccccc" | smallint<br>
+
| bgcolor="#cccccc" | smallint<br>  
| align="center" | f<br>
+
| align="center" | f<br>  
| align="center" | <br>
+
| align="center" | <br>  
| align="center" | g<br>
+
| align="center" | g<br>  
| align="center" | <br>
+
| align="center" | <br>  
| align="center" | f<br>
+
| align="center" | f<br>  
| align="center" | f<br>
+
| align="center" | f<br>  
| align="center" | f<br>
+
| align="center" | f<br>  
| align="center" | f<br>
+
| align="center" | f<br>  
| align="center" | f<br>
+
| align="center" | f<br>  
| align="center" | a<br>
+
| align="center" | a<br>  
| align="center" | d<br>
+
| align="center" | d<br>  
 
| align="center" | <br>
 
| align="center" | <br>
 
|-
 
|-
| bgcolor="#cccccc" | string<br>
+
| bgcolor="#cccccc" | string<br>  
| align="center" | d<br>
+
| align="center" | d<br>  
| align="center" | <br>
+
| align="center" | <br>  
| align="center" | e<br>
+
| align="center" | e<br>  
| align="center" | k<br>
+
| align="center" | k<br>  
| align="center" | d<br>
+
| align="center" | d<br>  
| align="center" | d<br>
+
| align="center" | d<br>  
| align="center" | d<br>
+
| align="center" | d<br>  
| align="center" | d<br>
+
| align="center" | d<br>  
| align="center" | d<br>
+
| align="center" | d<br>  
| align="center" | d<br>
+
| align="center" | d<br>  
| align="center" | a<br>
+
| align="center" | a<br>  
 
| align="center" | c<br>
 
| align="center" | c<br>
 
|-
 
|-
| bgcolor="#cccccc" | timestamp<br>
+
| bgcolor="#cccccc" | timestamp<br>  
| align="center" | <br>
+
| align="center" | <br>  
| align="center" | <br>
+
| align="center" | <br>  
| align="center" | <br>
+
| align="center" | <br>  
| align="center" | <br>
+
| align="center" | <br>  
| align="center" | <br>
+
| align="center" | <br>  
| align="center" | <br>
+
| align="center" | <br>  
| align="center" | <br>
+
| align="center" | <br>  
| align="center" | <br>
+
| align="center" | <br>  
| align="center" | <br>
+
| align="center" | <br>  
| align="center" | <br>
+
| align="center" | <br>  
| align="center" | c<br>
+
| align="center" | c<br>  
 
| align="center" | j<br>
 
| align="center" | j<br>
 
|}
 
|}
Line 202: Line 202:
 
b = Booleans convert to strings as "true" or "false" (lowercase).  
 
b = Booleans convert to strings as "true" or "false" (lowercase).  
  
c = <span style="background: #ffa500">Strings convert to/from timestamps using a predefined format for timestamps (to be defined later).&nbsp; The required fields come from the timestamp's pattern.&nbsp;&nbsp; The conversions are not controlled by variables like RBD's defaultTimestampFormat.&nbsp; Because of this, we can't convert from a string to a timestamp with no pattern.&nbsp; We can convert from a timestamp with no pattern to a string.&nbsp; Functions will be provided which convert to/from strings and timestamps with a format string supplied by the program.</span>  
+
c = <span style="background: none repeat scroll 0% 0% rgb(255, 165, 0);">Strings convert to/from timestamps using a predefined format for timestamps (to be defined later).&nbsp; The required fields come from the timestamp's pattern.&nbsp;&nbsp; The conversions are not controlled by variables like RBD's defaultTimestampFormat.&nbsp; Because of this, we can't convert from a string to a timestamp with no pattern.&nbsp; We can convert from a timestamp with no pattern to a string.&nbsp; Functions will be provided which convert to/from strings and timestamps with a format string supplied by the program.</span>  
  
d = <span style="background: #ffa500">Strings convert to/from numbers using our literal syntax for numbers.&nbsp; The conversions are not controlled by variables like RBD's defaultNumericFormat.&nbsp; Functions will be provided which convert to/from strings and numbers with a format string supplied by the program.</span>  
+
d = <span style="background: none repeat scroll 0% 0% rgb(255, 165, 0);">Strings convert to/from numbers using our literal syntax for numbers.&nbsp; The conversions are not controlled by variables like RBD's defaultNumericFormat.&nbsp; Functions will be provided which convert to/from strings and numbers with a format string supplied by the program.</span>  
  
 
e = Strings convert to bytes using the bit pattern of the Unicode characters in the string.  
 
e = Strings convert to bytes using the bit pattern of the Unicode characters in the string.  
Line 210: Line 210:
 
f = All numeric types are compatible with each other, but some conversions can result in overflow or truncation.  
 
f = All numeric types are compatible with each other, but some conversions can result in overflow or truncation.  
  
g = Numeric types convert to bytes using the number's bit pattern. When the bytes type includes a length (i.e. "bytes(4)" not just "bytes") the conversion is legal only if the size of the number in bytes equals the length of the bytes type.<br>
+
g = Numeric types convert to bytes using the number's bit pattern. When the bytes type includes a length (i.e. "bytes(4)" not just "bytes") the conversion is legal only if the size of the number in bytes equals the length of the bytes type.<br>  
  
h = Conversion from bytes to numeric types is done by interpreting the bytes data as a value in the format of the numeric type.&nbsp; If the bytes type includes a length (i.e. "bytes(4)" not just "bytes") the conversion is legal only if the size of the number in bytes equals the length of the bytes type.&nbsp; If the bytes type doesn't include a length, the conversion will fail at run time if the size of the number in bytes is not equal to the length of the bytes data.<br>
+
h = Conversion from bytes to numeric types is done by interpreting the bytes data as a value in the format of the numeric type.&nbsp; If the bytes type includes a length (i.e. "bytes(4)" not just "bytes") the conversion is legal only if the size of the number in bytes equals the length of the bytes type.&nbsp; If the bytes type doesn't include a length, the conversion will fail at run time if the size of the number in bytes is not equal to the length of the bytes data.<br>  
  
i = This is like h, with the additional rule that the decimal type must include a length.&nbsp; (Without the decimal's length we don't know how to interpret the bytes data.)<br>
+
i = This is like h, with the additional rule that the decimal type must include a length.&nbsp; (Without the decimal's length we don't know how to interpret the bytes data.)<br>  
  
j = Conversion is necessary if the "from" and "to" types both have parameters (i.e. "bytes(4)" not just "bytes"), and the type parameters aren't identical.<br>
+
j = Conversion is necessary if the "from" and "to" types both have parameters (i.e. "bytes(4)" not just "bytes"), and the type parameters aren't identical.<br>  
  
k = <span style="background: #ffa500">Strings convert to/from dates using a predefined format for dates (to be defined later). The conversions are not controlled by variables like RBD's defaultDateFormat. Functions will be provided which convert to/from strings and dates with a format string supplied by the program.</span><br>
+
k = <span style="background: none repeat scroll 0% 0% rgb(255, 165, 0);">Strings convert to/from dates using a predefined format for dates (to be defined later). The conversions are not controlled by variables like RBD's defaultDateFormat. Functions will be provided which convert to/from strings and dates with a format string supplied by the program.</span><br>  
  
<br>
+
<br>  
  
{| border="1" cellspacing="1" cellpadding="1" width="400"
+
{| cellspacing="1" cellpadding="1" border="1" style="width: 461px; height: 587px;"
 
|-
 
|-
 
| bgcolor="#999999" align="center" | '''''Conversions Between Primitive Types<sup>1</sup>'''''  
 
| bgcolor="#999999" align="center" | '''''Conversions Between Primitive Types<sup>1</sup>'''''  
Line 231: Line 231:
 
| bgcolor="#cccccc" | ''Any to everything''  
 
| bgcolor="#cccccc" | ''Any to everything''  
 
| <br>2d - entire table (to verify validation lets all the valid conversions through and catches invalid)  
 
| <br>2d - entire table (to verify validation lets all the valid conversions through and catches invalid)  
| <br>
+
| <br>  
 
| 1d<br>
 
| 1d<br>
 
|-
 
|-
 
| bgcolor="#cccccc" | ''Everything to any''  
 
| bgcolor="#cccccc" | ''Everything to any''  
| <br>--
+
| <br>--  
| <br>
+
| <br>  
 
| 1d<br>
 
| 1d<br>
 
|-
 
|-
 
| bgcolor="#cccccc" | ''Conversion Matrix b''  
 
| bgcolor="#cccccc" | ''Conversion Matrix b''  
| <br>--
+
| <br>--  
| <br>
+
| 0.1d<br>  
 
| done<br>
 
| done<br>
 
|-
 
|-
 
| bgcolor="#cccccc" | ''Conversion Matrix c''  
 
| bgcolor="#cccccc" | ''Conversion Matrix c''  
| <br>--
+
| <br>--  
| <br>
+
| 0.1d<br>  
 
| 1d<br>
 
| 1d<br>
 
|-
 
|-
 
| bgcolor="#cccccc" | ''Conversion Matrix d''  
 
| bgcolor="#cccccc" | ''Conversion Matrix d''  
| --<br>
+
| --<br>  
| <br>
+
| 0.2d<br>  
 
| 1d<br>
 
| 1d<br>
 
|-
 
|-
 
| bgcolor="#cccccc" | ''Conversion Matrix e''  
 
| bgcolor="#cccccc" | ''Conversion Matrix e''  
| <br>--
+
| <br>--  
| <br>
+
| 0.5d<br>  
 
| 0.5d<br>
 
| 0.5d<br>
 
|-
 
|-
 
| bgcolor="#cccccc" | ''Conversion Matrix f''  
 
| bgcolor="#cccccc" | ''Conversion Matrix f''  
| <br>--
+
| <br>--  
| <br>
+
| done<br>  
 
| 2d<br>
 
| 2d<br>
 
|-
 
|-
 
| bgcolor="#cccccc" | ''Conversion Matrix g''  
 
| bgcolor="#cccccc" | ''Conversion Matrix g''  
| <br>--
+
| <br>--  
| <br>
+
| 1d<br>  
 
| 1d<br>
 
| 1d<br>
 
|-
 
|-
| bgcolor="#cccccc" | ''Conversion Matrix h''<br>
+
| bgcolor="#cccccc" | ''Conversion Matrix h''<br>  
| <br>--
+
| <br>--  
| <br>
+
| 2d<br>  
 
| 2d<br>
 
| 2d<br>
 
|-
 
|-
| bgcolor="#cccccc" | ''Conversion Matrix i''<br>
+
| bgcolor="#cccccc" | ''Conversion Matrix i''<br>  
| <br>--
+
| <br>--  
| <br>
+
| 1d<br>  
 
| 1d<br>
 
| 1d<br>
 
|-
 
|-
| bgcolor="#cccccc" | ''Conversion Matrix j''<br>
+
| bgcolor="#cccccc" | ''Conversion Matrix j''<br>  
| <br>--
+
| <br>--  
| <br>
+
| 1d<br>  
 
| 1d<br>
 
| 1d<br>
 
|-
 
|-
 
| bgcolor="#cccccc" | ''Conversion Matrix k''  
 
| bgcolor="#cccccc" | ''Conversion Matrix k''  
| --
+
| --  
|  
+
| 1d
 
| 1d
 
| 1d
 
|-
 
|-
| bgcolor="#cccccc" | ''Numeric overflows''<sup>2</sup><br>
+
| bgcolor="#cccccc" | ''Numeric overflows''<sup>2</sup><br>  
| <br>done
+
| <br>done  
| <br>
+
| <br>  
 
| <br>
 
| <br>
 
|}
 
|}
Line 297: Line 297:
 
'''Notes on Table 4'''  
 
'''Notes on Table 4'''  
  
#We'll document error conditions of conversions, and their resulting exceptions. Whenever possible this documentation will be comments in the EGL source file for a type. <br>
+
#We'll document error conditions of conversions, and their resulting exceptions. Whenever possible this documentation will be comments in the EGL source file for a type. <br>  
#<span style="background: #ffa500">Our philosophy is that we can't make EDT be both efficient, and also behave the same in every environment when it comes to edge cases like numeric overflow. This means that in normal circumstances conversions to numeric types do not check for overflow: EGL does whatever the underlying language does in that situation. There will be special syntax for users to indicate that overflow checking is required. The syntax is To Be Determined. It may be an operation, something that looks like a function call where the source expression and target variable are passed in. What happens when an overflow is detected? We might throw an exception, but that's also To Be Determined.</span>
+
#<span style="background: none repeat scroll 0% 0% rgb(255, 165, 0);">Our philosophy is that we can't make EDT be both efficient, and also behave the same in every environment when it comes to edge cases like numeric overflow. This means that in normal circumstances conversions to numeric types do not check for overflow: EGL does whatever the underlying language does in that situation. There will be special syntax for users to indicate that overflow checking is required. The syntax is To Be Determined. It may be an operation, something that looks like a function call where the source expression and target variable are passed in. What happens when an overflow is detected? We might throw an exception, but that's also To Be Determined.</span>
  
 
<br>
 
<br>

Revision as of 13:59, 21 July 2011

Please see the parent of this page, EDT:EGL Language.

Conversions Between Primitive Types (Table 4)

Conversion Matrix

To see if there's a conversion from one type to another, find the cell in "from" type's row and the "to" type's column.

This matrix might contain differences from RBD.


bigint
boolean
bytes
date
decimal
float
  int 
number
smallfloat
smallint
string
timestamp
bigint
a

g

f
f
f
f
f
f
d

boolean

a








b

bytes
h

j

i
h
h

h
h


date



a






k

decimal
f

g

j
f
f
f
f
f
d

float
f

g

f
a
f
f
f
f
d

int
f

g

f
f
a
f
f
f
d

number
f

g

f
f
f
a
f
f
d

smallfloat
f

g

f
f
f
f
a
f
d

smallint
f

g

f
f
f
f
f
a
d

string
d

e
k
d
d
d
d
d
d
a
c
timestamp










c
j

Key

blank cell = The types are incompatible.  Conversion is not supported.

a = Same types (not a conversion).

b = Booleans convert to strings as "true" or "false" (lowercase).

c = Strings convert to/from timestamps using a predefined format for timestamps (to be defined later).  The required fields come from the timestamp's pattern.   The conversions are not controlled by variables like RBD's defaultTimestampFormat.  Because of this, we can't convert from a string to a timestamp with no pattern.  We can convert from a timestamp with no pattern to a string.  Functions will be provided which convert to/from strings and timestamps with a format string supplied by the program.

d = Strings convert to/from numbers using our literal syntax for numbers.  The conversions are not controlled by variables like RBD's defaultNumericFormat.  Functions will be provided which convert to/from strings and numbers with a format string supplied by the program.

e = Strings convert to bytes using the bit pattern of the Unicode characters in the string.

f = All numeric types are compatible with each other, but some conversions can result in overflow or truncation.

g = Numeric types convert to bytes using the number's bit pattern. When the bytes type includes a length (i.e. "bytes(4)" not just "bytes") the conversion is legal only if the size of the number in bytes equals the length of the bytes type.

h = Conversion from bytes to numeric types is done by interpreting the bytes data as a value in the format of the numeric type.  If the bytes type includes a length (i.e. "bytes(4)" not just "bytes") the conversion is legal only if the size of the number in bytes equals the length of the bytes type.  If the bytes type doesn't include a length, the conversion will fail at run time if the size of the number in bytes is not equal to the length of the bytes data.

i = This is like h, with the additional rule that the decimal type must include a length.  (Without the decimal's length we don't know how to interpret the bytes data.)

j = Conversion is necessary if the "from" and "to" types both have parameters (i.e. "bytes(4)" not just "bytes"), and the type parameters aren't identical.

k = Strings convert to/from dates using a predefined format for dates (to be defined later). The conversions are not controlled by variables like RBD's defaultDateFormat. Functions will be provided which convert to/from strings and dates with a format string supplied by the program.


Conversions Between Primitive Types1 Core JavaScript Java
Any to everything
2d - entire table (to verify validation lets all the valid conversions through and catches invalid)

1d
Everything to any
--

1d
Conversion Matrix b
--
0.1d
done
Conversion Matrix c
--
0.1d
1d
Conversion Matrix d --
0.2d
1d
Conversion Matrix e
--
0.5d
0.5d
Conversion Matrix f
--
done
2d
Conversion Matrix g
--
1d
1d
Conversion Matrix h

--
2d
2d
Conversion Matrix i

--
1d
1d
Conversion Matrix j

--
1d
1d
Conversion Matrix k -- 1d 1d
Numeric overflows2

done


Notes on Table 4

  1. We'll document error conditions of conversions, and their resulting exceptions. Whenever possible this documentation will be comments in the EGL source file for a type.
  2. Our philosophy is that we can't make EDT be both efficient, and also behave the same in every environment when it comes to edge cases like numeric overflow. This means that in normal circumstances conversions to numeric types do not check for overflow: EGL does whatever the underlying language does in that situation. There will be special syntax for users to indicate that overflow checking is required. The syntax is To Be Determined. It may be an operation, something that looks like a function call where the source expression and target variable are passed in. What happens when an overflow is detected? We might throw an exception, but that's also To Be Determined.


Back to the top