Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Clarify type conversions and meanings" #250

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 26 additions & 35 deletions versions/development/SPEC.md
Original file line number Diff line number Diff line change
Expand Up @@ -305,13 +305,7 @@ For more details on the postfix quantifiers, see the section on [Optional Parame

For more information on type and how they are used to construct commands and define outputs of tasks, see the [Data Types & Serialization](#data-types--serialization) section.

#### Numeric Behavior

`Int` and `Float` are the numeric types.
`Int` can be used to hold a signed Integer in the range \[-2^63, 2^63).
`Float` is a finite 64-bit IEEE-754 floating point number.

#### Custom Types
#### Custom Types

WDL provides the ability to define custom compound types called `Structs`. `Structs` are defined directly in the WDL and are usable like any other type.
For more information on their usage, see the section on [Structs](#struct-definition)
Expand Down Expand Up @@ -490,14 +484,23 @@ Below are the valid results for operators on types. Any combination not in the
|-----------|-----------|-----------------|---------|---------|
|`Boolean`|`==`|`Boolean`|`Boolean`||
|`Boolean`|`!=`|`Boolean`|`Boolean`||
|`Boolean`|`>`|`Boolean`|`Boolean`||
|`Boolean`|`>=`|`Boolean`|`Boolean`||
|`Boolean`|`<`|`Boolean`|`Boolean`||
|`Boolean`|`<=`|`Boolean`|`Boolean`||
|`Boolean`|`||`|`Boolean`|`Boolean`||
|`Boolean`|`&&`|`Boolean`|`Boolean`||
|`File`|`+`|`File`|`File`|Append file paths|
|`File`|`==`|`File`|`Boolean`||
|`File`|`!=`|`File`|`Boolean`||
|`File`|`+`|`String`|`File`||
|`File`|`==`|`String`|`Boolean`||
|`File`|`!=`|`String`|`Boolean`||
|`Float`|`+`|`Float`|`Float`||
|`Float`|`-`|`Float`|`Float`||
|`Float`|`*`|`Float`|`Float`||
|`Float`|`/`|`Float`|`Float`||
|`Float`|`%`|`Float`|`Float`||
|`Float`|`==`|`Float`|`Boolean`||
|`Float`|`!=`|`Float`|`Boolean`||
|`Float`|`>`|`Float`|`Boolean`||
Expand All @@ -508,14 +511,21 @@ Below are the valid results for operators on types. Any combination not in the
|`Float`|`-`|`Int`|`Float`||
|`Float`|`*`|`Int`|`Float`||
|`Float`|`/`|`Int`|`Float`||
|`Float`|`%`|`Int`|`Float`||
|`Float`|`==`|`Int`|`Boolean`||
|`Float`|`!=`|`Int`|`Boolean`||
|`Float`|`>`|`Int`|`Boolean`||
|`Float`|`>=`|`Int`|`Boolean`||
|`Float`|`<`|`Int`|`Boolean`||
|`Float`|`<=`|`Int`|`Boolean`||
|`Float`|`+`|`String`|`String`||
|`Int`|`+`|`Float`|`Float`||
|`Int`|`-`|`Float`|`Float`||
|`Int`|`*`|`Float`|`Float`||
|`Int`|`/`|`Float`|`Float`||
|`Int`|`%`|`Float`|`Float`||
|`Int`|`==`|`Float`|`Boolean`||
|`Int`|`!=`|`Float`|`Boolean`||
|`Int`|`>`|`Float`|`Boolean`||
|`Int`|`>=`|`Float`|`Boolean`||
|`Int`|`<`|`Float`|`Boolean`||
Expand All @@ -531,22 +541,22 @@ Below are the valid results for operators on types. Any combination not in the
|`Int`|`>=`|`Int`|`Boolean`||
|`Int`|`<`|`Int`|`Boolean`||
|`Int`|`<=`|`Int`|`Boolean`||
|`String`|`+`|`String`|`String`|Concatenation|
|`Int`|`+`|`String`|`String`||
|`String`|`+`|`Float`|`String`||
|`String`|`+`|`Int`|`String`||
|`String`|`+`|`String`|`String`||
|`String`|`==`|`String`|`Boolean`||
|`String`|`!=`|`String`|`Boolean`||
|`String`|`>`|`String`|`Boolean`||
|`String`|`>=`|`String`|`Boolean`||
|`String`|`<`|`String`|`Boolean`||
|`String`|`<=`|`String`|`Boolean`||
||`-`|`Float`|`Float`||
||`+`|`Float`|`Float`||
||`-`|`Int`|`Int`||
||`+`|`Int`|`Int`||
||`!`|`Boolean`|`Boolean`||

Note: In expressions using an operator with mismatched numeric types,
the `Int` will be cast to `Float` and the result will be `Float`.
This will cause loss of precision if the `Int` is too large to be represented exactly by the `Float`.
The `Float` can be converted to `Int` with the `ceil`, `round` or `floor` functions if needed.

#### If then else

This is an operator that takes three arguments, a condition expression, an if-true expression and an if-false expression. The condition is always evaluated. If the condition is true then the if-true value is evaluated and returned. If the condition is false, the if-false expression is evaluated and returned. The return type of the if-then-else should be the same, regardless of which side is evaluated or runtime problems might occur.
Expand Down Expand Up @@ -575,6 +585,7 @@ runtime {
| 10 | Index | left-to-right | x[y] |
| 9 | Function Call | left-to-right | x(y,z,...) |
| 8 | Logical NOT | right-to-left | !x |
| | Unary Plus | right-to-left | +x |
| | Unary Negation | right-to-left | -x |
| 7 | Multiplication | left-to-right | x*y |
| | Division | left-to-right | x/y |
Expand All @@ -589,6 +600,7 @@ runtime {
| | Inequality | left-to-right | x!=y |
| 3 | Logical AND | left-to-right | x&&y |
| 2 | Logical OR | left-to-right | x\|\|y |
| 1 | Assignment | right-to-left | x=y |

### Member Access

Expand Down Expand Up @@ -1088,28 +1100,7 @@ task example {
}
```

Any `${expression}` inside of a string literal must be replaced with the value of the expression. If prefix were specified as `"foobar"`, then `"${prefix}.out"` would be evaluated to `"foobar.out"`.

Different types for the expression are formatted in different ways.
`String` is substituted directly.
`File` is substituted as if it were a `String`.
`Int` is formatted without leading zeros (unless the value is `0`), with a leading `-` if the value is negative.
`Float` is printed in the style `[-]ddd.ddd`, with 6 digits after the decimal point.
The expression cannot have the value of any other type.

```
"${"abc"}" == "abc"

File def = "hij"
"${def}" == "hij"

"${5}" == "5"

"${3.141}" == "3.141000"
"${3.141 * 1E-10}" == "0.000000"
"${3.141 * 1E10}" == "31410000000.000000"
```

Any `${identifier}` inside of a string literal must be replaced with the value of the identifier. If prefix were specified as `foobar`, then `"${prefix}.out"` would be evaluated to `"foobar.out"`.

### Runtime Section

Expand Down