-
-
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.
Deprecate the `:` (colon) method from Object. Starting with Sidef v4.0 it will be removed from Object entirely, and only be used to create Complex and standard named param- eter syntax for Blocks (when its LHS is a bareword). The utility of `:` has been bisected into the `:` (fat/fullwidth colon; more easily written `¦`) and `⫶` (triple colon). `:` as a Pair constructor remains for now, but code using it should be updated to use the new methods. - Object.:, the fullwidth colon U+FF1A: force creation of a Pair from self and the first argument. - Object.¦, the broken bar U+A6: alias for `:` with a shorter hex value to type when using Unicode input methods. - ⫶, the triple-colon operator U+2AF6: force creation of a NamedParam with the object on its LHS as the name. Whereas the normal NamedParam colon operator `a: val` expects a bareword on its LHS, the triple-colon evaluates its left hand side and therefore allows any value from a names or expressions as the name in a NamedParam. Previously, it wasn't possible to generate NamedParams without `eval` because of the bareword restriction. #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.
- Loading branch information
Showing
10 changed files
with
60 additions
and
23 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