Closed postmodern closed 9 years ago
As an alias to size? What is the goal of this?
MRI's String aliases the two, so I guess an alias is fine. Have you thought of using Forwardable to expose all String methods?
I think the goal is to accommodate people who call #length
on their strings, arrays and socks instead of #size
. Granted, people say "big slice" but not "long slice", but since a Parslet::Slice is a segment of a string somehow, "length" feels right.
Just to clarify, are parslet users encourages to coerce Slices back into Strings, or leave them as Slices?
Love you guys - you just preempted all the discussion on the matter ;)
Slices are supposed to be string-like - but will never become strings, otherwise I would have opted for subclassing String. They are somewhat 'frozen' strings; for any real use, you should cast them to other data types. And since we have size and since .. matz thought variety was good, here goes:
Can you change the code of #length
into just aliasing #size
? I want to press the green button on this one, but can't right now ;)
Amended and force pushed.
Add a
#length
method to complement#size
.