Author: masak Date: 2010-06-02 12:10:26 +0200 (Wed, 02 Jun 2010) New Revision: 31044
Modified: docs/Perl6/Spec/S32-setting-library/Containers.pod Log: [S32/Containers] Buf.new parameter no longer slurpy Feedback from implementors suggests that this would be too inefficient. Also, might be good to highlight that the array is an array in the constructor. Also, this makes conversion back and forth Buf<->Array look more symmetrical. Modified: docs/Perl6/Spec/S32-setting-library/Containers.pod =================================================================== --- docs/Perl6/Spec/S32-setting-library/Containers.pod 2010-06-02 10:10:22 UTC (rev 31043) +++ docs/Perl6/Spec/S32-setting-library/Containers.pod 2010-06-02 10:10:26 UTC (rev 31044) @@ -797,27 +797,31 @@ class Buf does Positional does Stringy {...} A mutable container for an array of integer values in contiguous -memory. The default constructor takes a slurpy array parameter of +memory. The default constructor takes a single array parameter of integers, the largest of which determines the actual type. So - Buf.new(:16<c3>, :16<B6>) # or - Buf.new(195, 182) # which is exactly the same + Buf.new([:16<c3>, :16<B6>]) # or + Buf.new([195, 182]) # which is exactly the same returns a C<buf8> containing two C<uint8> items, while - Buf.new(256) + Buf.new([256]) returns a C<buf16> which consists of a single C<uint16>. To explicit request a C<Buf> of a specific size, you can use - Buf.new(127, :size(16)) # returns a buf16 - Buf.new(1024, :size(8)) # dies, because 1024 >= 2**8 + Buf.new([127], :size(16)) # returns a buf16 + Buf.new([1024], :size(8)) # dies, because 1024 >= 2**8 Subtypes with additional constraints like C<utf8> (which only allows valid UTF-8 byte sequences) exist and provide similar constructors. See L<S02/Built-In Data Types>. +The array in the constructor used to be slurpy rather than positional, but +the former was deemed to be too inefficient (during signature construction) +for arrays of many elements. + =head3 Methods =over