Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow Nil to represent holes in sparse arrays
This commit affects the way arrays are rendered with .raku, and it affects the way Nil is interpreted as a value when initializing an array. This is achieved by the following conceptual changes: 1. in .raku, output a hole (nqp::isnull) as `Nil` To achieve this, several Iterator classes have their private method `!hole` turned into a outside visible method `hole` with the "is implementation-detail" trait. This allows Array.raku to override the handling of a hole by mixing in a "hole" method into the iterator that produces "Nil". 2. in STORE and circumfix:<[ ]> (and its helpers), interprete Nil as *skipping* an element to be initialized. If there was only one element specified, and it was Nil, then return an empty Array. 3. fix some Rakudo::Internals helper methods to recognize nqp::null values without throwing a tantrum. This breaks a few tests in roast, that expect that [Nil] will return [Any], where now it will return [Nil]. There is no further test breakage. This does *not* fix the case of Nil in arrays constrained with a type smiley. Generating the .raku of these is fine, but it won't roundtrip because `my Int:D @A = 1,Nil,3` is a runtime error. FWIW, I think this is actually incorrect behaviour, or at least unproductive behaviour. This work was done in reply to Raku/problem-solving#279 One of the proposed solutions was to introduce a Hole class with special semantics. Should that proposal be accepted, then it is mostly replacing `Nil` by `Hole` in most of this commit.
- Loading branch information
Showing
4 changed files
with
97 additions
and
48 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