Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search

[REBOL] Re: to-path newline problem?

From: joel:neely:fedex at: 14-Aug-2001 13:07

Hi, Holger, Holger Kruse wrote:
> When REBOL loads a script and saves or molds it back, it attempts > to preserve the positions of line feeds in each block, to make the > output look closer to the original. This is very useful, e.g., for > structured configuration files. >
It just seems that this is a case of the tail wagging the dog. I can see the benefit of doing so in a few rare cases, but always??? It seems rather analogous to LOAD vs. LOAD/MARKUP, where the unusual (or more complex) case is signalled by the presence of a refinement.
> Internally in REBOL, paths are very similar to blocks. They are > both subtypes of any-block!. That's why converting a block which > has those "line feed hints" in it to a path preserves the hints, > and why molding such a path reproduces them in the output as well. > > At the moment it is not possible to manipulate the line feed hints > from the REBOL level. This is planned for a future version. Copying > values to a new block resets the hints though. >
How? Any standard way of simply "copying values" that I can think of doesn't do the trick (except for discarding the last "hint").
>> b: [
[ 1 [ 4 [ 16 [ ] == [ 1 4 16 ]
>> b1: copy b print mold b1
[ 1 4 16]
>> b2: copy/deep print mold b2
[ 1 4 9 16]
>> b3: [] foreach be b [append b3 be] print mold b3
[ 1 4 16]
>> b4: compose [(b)] print mold b4
[ 1 4 16] Of course one can always do something like
>> b5: [] foreach be b [append b5 0 + be] print mold b5
[1 4 16] but that is hardly the same as simply copying, as it requires knowing an operator and identity element suitable for the type(s) of the values in the block! Any suggestions welcome! -jn- -- This sentence contradicts itself -- no actually it doesn't. -- Doug Hofstadter joel<dot>neely<at>fedex<dot>com