-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace
Object.:
with :(U+FF1A) and ⫶ (U+2AF6)
Breaking change, to remove the `:` (colon) operator from Object. Its use has been bisected into the : (fat/fullwidth colon) and ⫶ (triple colon). Previously the appearance of a `:` in the syntax was ambiguous, so it has been disambiguated to mean only NamedParam (when the LHS is a bareword) or Complex (when the LHS is a real number). There is no direct overlap between these two syntaxes, but it's now possible to create a NamedParam with a real number as its name. : remains as a first-class operator to create NamedParams using barewords, and to construct Complex literals. - :, the fullwidth colon U+FF1A: force creation of a Pair from self and the first argument. - ⫶, the triple-colon operator U+2AF6: force creation of a NamedParam with the object on its LHS as the name. In other words, whereas the normal NamedParam colon operator expects a bareword on its LHS, the triple-colon evaluates its left hand side and therefore allows runtime-computed objects as the names in NamedParams, rather than forcing only barewords. Previously it was not possible to iterate an array of strings and generate NamedParams from them, because the : (colon) NamedParam operator (understandably) doesn't even accept a parenthesised expression on its LHS. Making NamedParam a directly invokable class would also be useful, but a shorthand is nice for this.
- Loading branch information
Showing
10 changed files
with
49 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#! /usr/bin/ruby | ||
|
||
var f = :name | ||
assert_eq(f⫶ 1 -> dump, name: 1 -> dump) | ||
assert_eq(f⫶ 1 -> dump, (f)⫶ 1 -> dump) | ||
assert_eq((f)⫶ 1 -> dump, name: 1 -> dump) | ||
assert_eq(:a⫶ 1 -> dump, a:1 -> dump) | ||
|
||
var n = 1 | ||
|
||
assert_ne(n: 2 -> dump, (n): 2 -> dump) | ||
assert_eq((n): 2 -> dump, 1: 2 -> dump) | ||
assert_eq(n:2, Pair(1, 2)) | ||
assert_eq(1:2, 1+2i) | ||
assert_eq(1:2, Pair(1, 2)) | ||
|
||
say "** Test passed!" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters