[#3006] mismatched quotation — "stevan apter" <apter@...>

ruby documentation uses a punctuation convention i've never seen

13 messages 2000/05/27

[ruby-talk:02783] Re: Array.pop and documentation [was: Append alias for Array.append?]

From: "Conrad Schneiker" <schneiker@...>
Date: 2000-05-12 10:00:45 UTC
List: ruby-talk #2783
Hi,

From: Aleksi Niemel#
#
# In message "[ruby-talk:02714] Re: Append alias for Array.append?"
#     on 00/05/10, Aleksi Niemel<aleksi.niemela@cinnober.com> writes:
#
# >|it would be nice to write
# >|
# >|  b[2,3] = a.pop(3)
#
# Matz:
# >How about 'b[2,3] = a.slice!(-3,3)'?
#
# Fun!
#
# I know there's people supporting Perl way and people feeling strongly
# (against) mixed up functionality. a.pop and a.pop(num) are clearly
different
# functionality. But I think Ruby favors Perl way, so it might not be bad
idea
# to have a.pop(num) version around too. At least on this case, I still
think
# my version is more readable than a.slice! version.

Well, I'd certainly have to agree about readibility.

# And surely is if the
# array is viewed as a stack (as a token stack in parser for example).

Or even if the array is viewed abstractly as a vector. Just think of pop and
unshift as being generalized "chop" operations, with slice being even more
generalized, but at the cost of being somewhat less mnemonic or somewhat
less natural.

For sake of simplicity and uniformity, it would be nice to have 0 and 1
parameter variations on slice, such as:

    slice_low
    slice_low(n)
    slice_high
    slice_high(n)
    slice(n,m)

where low and high refer to the end of the array with lowest and highest
array index, and where each of these methods would have a corresponding !
method, and there could be a complementary set of fortuitously named splice
methods for likewise more directly and systematically expressing ways of
adding elements to arrays..

Of course, even if everyone else liked this slice and splice system for
unifying the naming of these related sorts of operations, it would still
have to wait for Ruby 3000. But in any case, I think it would make for
easier to learn, easier to read, and easier to understand code compared to
what is presently used in Ruby (let alone in Perl).

Conrad




In This Thread

Prev Next