[REBOL] Re: Does REBOL cons?
From: tim-johnsons::web::com at: 15-Mar-2006 14:52
* Jeff Massung <massung-gmail.com> [060315 13:48]:
> My question was more fundamental: "Does REBOL use consing for its lists
> internally?"
the lisp cons is *not* internal, it is produced by a C code that
adds an item to a linked (I think) list.
The rebol 'insert action value is produced by C code that resizes
a contiguous block of memory with the value as the first item.
I think that rebol lists are linked lists tho' and I *believe*
that 'insert acts on them too. But take note of the return value
(cons CAR CDR) returns new list.
'insert returns the insertion point.
Here's a nother quick rebol console session:
>> test: [2 3 4]
== [2 3 4]
>> res: insert test 1
== [2 3 4]
>> res
== [2 3 4]
>> test
== [1 2 3 4]
>> help insert ;; see the underscored line
USAGE:
INSERT series value /part range /only /dup count
DESCRIPTION:
Inserts a value into a series and returns the series after the insert.
----------------------------------------------------------------------
^^^^^^^^^^^^^^^^^^^^^^^^^^^
INSERT is an action value.
ARGUMENTS:
series -- Series at point to insert (Type: series port bitset)
value -- The value to insert (Type: any-type)
REFINEMENTS:
/part -- Limits to a given length or position.
range -- (Type: number series port)
/only -- Inserts a series as a series.
/dup -- Duplicates the insert a specified number of times.
count -- (Type: number)
:-) Watch them/thar return values, they will surprise you.
Fortunately, you're familiar with lisp so you will be looking for
return values from loops and conditionals. That's something else I
hand to get used to.
HTH
tim
--
Tim Johnson <tim-johnsons-web.com>
http://www.alaska-internet-solutions.com