I didn't join all the dots.
My point is that [all] but {first,last} have simple definitions in terms
of #copyFrom:to: and that if you want to make them accept oversize counts,
you either have to change the definition of #copyFrom:to: (bad idea) or
cut these methods loose from #copyFrom:to: and define them in terms of
something else.
I should also explain that there are at least four plausible
definitions:
�� (1) 'the first n elements of x' is exactly n elements long
�� �� �� (current Squeak and Pharo 8)
�� (2) 'the first n elements of x' is (x size min: n) elements long
�� (3) 'the first n elements of x' is exactly |n| elements long;
�� �� �� it's the first n if n >= 0 or the last |n| if n <= 0.
�� (34 'the first n elements of x' is exactly n elements long
�� �� �� and if x size < n the last n - x size elements are the
�� �� �� default value for n (nil for objects, zero for numbers,
�� �� �� blank for characters).
Number (3) is the original APL\360 definition found in the 1968
manual from IBM.�� While the sign dependence wrecks the lovely
v = (n .take v) , (n .drop v)
property, APL wants to let you pick *any* corner of an array
with *any* number of subscripts in a single operator.
Number (4) is the definition found in the APL standard (the
1993 draft, anyway).
My resolution was to say that #first: (#last:) and #take: are
DIFFERENT operations, where
�� ��take: n
�� �� �� ^n positive
�� �� �� �� ��ifTrue:�� [self first: (self size min: n)]
�� �� �� �� ��ifFalse: [self last:�� (self size min: n negated)]
�� ��drop: n
�� �� �� ^n positive
�� �� �� �� ��ifTrue:�� [self allButFirst: (self size min: n)]
�� �� �� �� ��ifFalse: [self allButLast:�� (self size min: n negated)]
They are different because they have different preconditions and
postconditions.�� Why did I not follow APL more closely?�� Because
I tried hard to define a #defaultElement for sequences and failed
to come up with anything coherent.�� Also, APL is just as happy
with floating point counts as with integer ones, provided they
are close enough to integral.
I should also point out that Pharo 8 does not respect the ANSI
semantics of #copyFrom:to:.�� Example:
�� ��'abc' copyFrom: 6 to: 0
should, according to the common specification, answer ''.
The result is instead a primitive failure in #basicNew:, of
all things.