[REBOL] Re: To copy or not to copy...
From: massung::gmail::com at: 1-May-2006 12:50
I posted this to the REBOL3 blog, but since it is old (at least this
thread), I wonder how much visibility it will get. So, I post it here for
everyone:
http://www.rebol.net/cgi-bin/r3blog.r?view=0006
---
I personally love the way REBOL does this now, primarily for performance
reasons. Whenever you are going to program something which can cause massive
performance problems (and copying of a series typically results in O(n^2)
problems down the road), making the programmer have to explicitly copy
something is good.
However, where REBOL's method gets a little frustrating is when it does this
to "constant" data. When I write "example" in code, I don't expect that
hard-coded data to ever change. But it can, and does. So I need to copy it.
I imagine that 90+% of the time, this occurs when constructing a list or
string of data, and so the copy is always desired.
So, I have a couple possible suggestions:
1. Make "constant" data just that - constant. Make the copy implicit when
binding a word to constant data. This would be quite easy, and would solve a
lot of headaches before they happen.
2. Have a series building operator (++ comes to mind from Haskell), which
acts as a copy + append. This is a little scarey, because I think most
people would just use ++ instead of append, and without knowing that it does
a copy, we're back to potential O(n^2) performance issues.
My 2 cents...
Jeff M.
--
massung-gmail.com