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 1: Line 1:
Please see the parent of this page, [[EDT:EGL_Language]].
+
Please see the parent of this page, [[EDT:EGL Language]].  
  
 
== Conversions Between Primitive Types (Table 4)  ==
 
== Conversions Between Primitive Types (Table 4)  ==
Line 5: Line 5:
 
=== Conversion Matrix  ===
 
=== 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.
+
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.  
  
 
{| cellspacing="1" cellpadding="1" border="1"
 
{| cellspacing="1" cellpadding="1" border="1"
Line 166: Line 166:
 
|}
 
|}
  
==== Key ====
+
==== Key ====
 +
 
 
blank cell = The types are incompatible.  Conversion is not supported.  
 
blank cell = The types are incompatible.  Conversion is not supported.  
  
Line 236: Line 237:
 
|-
 
|-
 
| bgcolor="#cccccc" | ''Conversion Matrix g''  
 
| bgcolor="#cccccc" | ''Conversion Matrix g''  
| <br>  
+
| <br>
 
| <br>  
 
| <br>  
 
| <br>  
 
| <br>  
 +
| <br>
 +
|-
 +
| bgcolor="#cccccc" | ''Numeric overflows''<sup>2</sup><br>
 +
| <br>
 +
| <br>
 +
| <br>
 
| <br>
 
| <br>
 
|}
 
|}
Line 244: Line 251:
 
'''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>
 +
 
 +
<br>

Revision as of 15:30, 7 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.


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

g
f
f
f
f
f
f
d

boolean

a







b

bytes
g

a
g
g
g
g
g
g


decimal
f

g
a
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
d
d
d
d
d
d
a
c
timestamp









c
a

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/from bytes using the number's bit pattern. When the bytes type includes a size (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.


Conversions Between Primitive Types1 Core JavaScript Java Debug
Any to everything



Everything to any



Conversion Matrix b



Conversion Matrix c



Conversion Matrix d



Conversion Matrix e



Conversion Matrix f



Conversion Matrix g



Numeric overflows2




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