Comments on: APPEND is native
REBOL 3.0 makes the following change:
| ||Change||The append function is now a native datatype action similar to insert.
| ||Reason||Performance is three times greater (and append is a commonly used function), and the /dup and /part refinements are now available (in addition to /only).
| ||Cost||Actually, the implementation takes less memory now.
Well, there's one obscure but common optimization down (insert tail ...). I wonder how many more are yet to come?|
Excellent. insert tail ... that was really weird, yeah ;-)|
Great! Could the help for /part also be updated to clarify what it does.
/part -- Limits to a given length or position.
/part -- applies range to value; i.e. copy/part value.
I don't use it very often, and sometimes I don't rememeber if the range applies to the overall length of the series or taking /part of the value (it's the latter). I think the reason I get confused is because change/part applies the range to the series, which is different than how insert applies it.
Of course, it makse sense, because you aren't changing part of the series with 'insert, so maybe 'change could use a clearer help string as well.
I second Gregg's suggestion (and support re-assessment of the built-in help in general).|
Thanks a lot!
I do "insert tail" a lot.
Is there a handy way to insert one or more steps back from the tail? Like:
insert back tail ...
Gregg: absolutely. A good suggestion.
Edoc: yes. But, as long as the can remain concise. The dictionary is supposed to expand on them, and perhaps in 3.0 we can integrate that feature better.
John: I do too. I've been thinking about better ways to handle tail related semantics. For example, back tail is such a common idiom. We almost need reverse ordinals, but what names to use? First-back, second-back, etc.? A bit wordy too.
since you are talking about tail semantics... hehe... I was trying to find an R3 topic to talk about this...
could you add 'END to the language as a standard word?
END is different than TAIL in that it would return the series AT its end (last item) instead of beyond it, basically:
BACK TAIL my-series
counting backwards is a standard feature of python and its very well tought out:
adapted to REBOL it could look like:
series/'2 ; '2 is invalid rebol, so could be used
This is very powerfull and replaces something like:
series/(length? series - 1) ; OR
first skip tail series -2
We could combine a couple words for the "back tail" idiom:
at-last: func [series [series!]] [back tail series]
And I'm sure it's possible to just use negative values with path notation and PICK/POKE to refer to tail-relative positions, but does it fit with REBOL's core semantics? If Carl didn't do it, I assume he didn't do it for a reason. And then can you make things consistent with, say, AT?
I've often thought that the way to extend and improve REBOL in some of these cases (some, not all) is to allow block parameters so you can have dialected versions of many functions. I think the series access and modification model can be done a lot of ways with dialects; I've built a few, and I'm sure others have as well.
That said, I think the at-last case is the most common, and supporting it would be good, even if nothing else is done. It also ties in with POP/PULL/TAKE as a common idiom (CHOP - to remove the last item in a series).
Post a Comment:
You can post a comment here. Keep it on-topic.