bug in append ?
[1/2] from: rotenca:telvia:it at: 1-Jan-2002 20:39
I do not know if this bug (?) is known: append fails in situation like:
append 'a/b/c 'd
because it does not get the series value with a get-word. It don't know if the
evaluation can be useful in other situations, like with ports.
The corrected version:
append: func [
{Appends a value to the tail of a series and returns the series head.}
series [series! port!]
value
/only "Appends a block value as a block"
][
head either only [
insert/only tail :series :value ;changed series with :series
] [
insert tail :series :value ;changed series with :series
]
]
---
Ciao
Romano
[2/2] from: al::bri::xtra::co::nz at: 2-Jan-2002 11:37
Romano wrote:
> I do not know if this bug (?) is known: append fails in situation like:
>
> append 'a/b/c 'd
'repend has a similar problem.
I've attached my %Patches.r script which corrects this and a few other
problems. It's also below my .sig as plain text.
Andrew Martin
ICQ: 26227169 http://valley.150m.com/
-><-
[
Rebol [
Name: 'Patches
Title: "Patches"
File: %Patches.r
Author: "Andrew Martin"
eMail: [Al--Bri--xtra--co--nz]
Date: 19/Oct/2001
]
; Wraps throw-on-error around 'function body.
if not equal? second third :function [catch] [
Function: func
head insert/only at load mold third :function 2 [catch]
compose/deep [
throw-on-error [
(copy/deep second :function)
]
]
]
; Fixes 'append so it works correctly with 'path! and doesn't evaluate
'Value.
if found? find mold second :append "insert tail series" [
Append: func [
{Appends a value to the tail of a series and returns the series
head.}
Series [series! port! path! word!]
Value [any-type!]
/Only "Appends a block value as a block."
][
head either Only [
insert/only tail :Series :Value
][
insert tail :Series :Value
]
]
]
; Fixes 'repend so it works correctly with 'path!.
if any [
unset? get/any 'repend ; Early Rebel/Core versions don't have
reppend.
found? find mold second :repend "insert tail series"
][
Repend: func [
{Appends a reduced value to a series and returns the series head.}
Series [series! port! path! word!]
Value [any-type!]
/Only "Appends a block value as a block."
][
head either Only [
insert/only tail :Series reduce :Value
][
insert tail :Series reduce :Value
]
]
]
; A better choice for http user-agent.
if not found? find system/schemes/http/user-agent "Mozilla" [
system/schemes/http/user-agent: rejoin [
"Mozilla" "/" "4.0"
" (Compatible; REBOL " rebol/version ")"
]
]
; Holger's patch to ftp protocol to eliminate multi-line return bug.
change/only skip find pick find second get in system/schemes/ftp/handler
'open
to-set-word 'parse-dir-list 4 'transfer-check -2
'net-utils/confirm/multiline
; Replaces 'days with 'weekdays, to match /weekdays refinement for date!
values.
rebol/Locale: make object! [
Months: rebol/locale/months
Weekdays: rebol/locale/days
]
; Modifies Extract to work with series! and adds /Only refinement.
Extract: function [
"Extracts every N-th value from a Series."
Series [series!]
N [integer!]
/Only "Appends a block value as a block."
][
New
][
New: make Series (length? Series) / N
do compose/deep [
forskip Series N [
(either Only ['insert/only]['insert]) tail New first Series
]
]
New
]
]
-- Attached file included as plaintext by Listar --
-- File: Patches.r
[
Rebol [
Name: 'Patches
Title: "Patches"
File: %Patches.r
Author: "Andrew Martin"
eMail: [Al--Bri--xtra--co--nz]
Date: 19/Oct/2001
]
; Wraps throw-on-error around 'function body.
if not equal? second third :function [catch] [
Function: func
head insert/only at load mold third :function 2 [catch]
compose/deep [
throw-on-error [
(copy/deep second :function)
]
]
]
; Fixes 'append so it works correctly with 'path! and doesn't evaluate 'Value.
if found? find mold second :append "insert tail series" [
Append: func [
{Appends a value to the tail of a series and returns the series head.}
Series [series! port! path! word!]
Value [any-type!]
/Only "Appends a block value as a block."
][
head either Only [
insert/only tail :Series :Value
][
insert tail :Series :Value
]
]
]
; Fixes 'repend so it works correctly with 'path!.
if any [
unset? get/any 'repend ; Early Rebel/Core versions don't have reppend.
found? find mold second :repend "insert tail series"
][
Repend: func [
{Appends a reduced value to a series and returns the series head.}
Series [series! port! path! word!]
Value [any-type!]
/Only "Appends a block value as a block."
][
head either Only [
insert/only tail :Series reduce :Value
][
insert tail :Series reduce :Value
]
]
]
; A better choice for http user-agent.
if not found? find system/schemes/http/user-agent "Mozilla" [
system/schemes/http/user-agent: rejoin [
"Mozilla" "/" "4.0"
" (Compatible; REBOL " rebol/version ")"
]
]
; Holger's patch to ftp protocol to eliminate multi-line return bug.
change/only skip find pick find second get in system/schemes/ftp/handler 'open
to-set-word 'parse-dir-list 4 'transfer-check -2 'net-utils/confirm/multiline
; Replaces 'days with 'weekdays, to match /weekdays refinement for date! values.
rebol/Locale: make object! [
Months: rebol/locale/months
Weekdays: rebol/locale/days
]
; Modifies Extract to work with series! and adds /Only refinement.
Extract: function [
"Extracts every N-th value from a Series."
Series [series!]
N [integer!]
/Only "Appends a block value as a block."
][
New
][
New: make Series (length? Series) / N
do compose/deep [
forskip Series N [
(either Only ['insert/only]['insert]) tail New first Series
]
]
New
]
]