Hi Jeff,

I think Volker is right, probably rebol doesn't
use consing as you describe it.

Here is my document to understand rebol values,
words, strings and blocks:

do http://www.lexicon.net/antonr/rebol/doc/rebol-values.r

It reflects my mental model.


Ahh! actually, the confusion may be that you think:

        blk: []
        insert blk [d]

inserts a block. It does not ! The above is equivalent to:

        blk: []
        insert blk 'd

That is, only a word was inserted into the blk.
After many iterations, the block is filled with many words
with the same name, "d".

To insert a block, you must use INSERT/ONLY:

        blk: []
        insert/only blk [d]

This results in:

        blk: [[d]]

(Same goes for APPEND/ONLY.)

Regards,

Anton.

> * Jeff Massung <[EMAIL PROTECTED]> [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 <[EMAIL PROTECTED]>
>       http://www.alaska-internet-solutions.com

-- 
To unsubscribe from the list, just send an email to 
lists at rebol.com with unsubscribe as the subject.

Reply via email to