Skip to content

Commit ca49d8d

Browse files
committed
FEAT: makes use of dynamic refinements or APPLY in the runtime mezz functions.
1 parent ce9a4ea commit ca49d8d

File tree

1 file changed

+8
-24
lines changed

1 file changed

+8
-24
lines changed

environment/functions.red

+8-24
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,7 @@ attempt: func [
2727
value [block!]
2828
/safer "Capture all possible errors and exceptions"
2929
][
30-
either safer [
31-
unless error? set/any 'value try/all :value [get/any 'value]
32-
][
33-
unless error? set/any 'value try :value [get/any 'value]
34-
]
30+
unless error? set/any 'value (apply 'try/:all [:value safer]) [get/any 'value]
3531
]
3632

3733
comment: func ["Consume but don't evaluate the next value" 'value][]
@@ -334,15 +330,7 @@ context [
334330
return: [logic! block!]
335331
][
336332
clear p-indent
337-
either case [
338-
parse/case/trace input rules :on-parse-event
339-
][
340-
either part [
341-
parse/part/trace input rules limit :on-parse-event
342-
][
343-
parse/trace input rules :on-parse-event
344-
]
345-
]
333+
parse/:case/:part/trace input rules limit :on-parse-event
346334
]
347335
]
348336

@@ -363,11 +351,7 @@ scan: func [
363351
/fast "Fast scanning, returns best guessed type"
364352
return: [datatype! none!] "Recognized or guessed type, or NONE on empty input"
365353
][
366-
either fast [
367-
either next [transcode/next/prescan buffer][transcode/prescan buffer]
368-
][
369-
either next [transcode/next/scan buffer][transcode/scan buffer]
370-
]
354+
apply 'transcode/:next/:scan/:prescan [buffer :next not fast fast]
371355
]
372356

373357
load: function [
@@ -767,7 +751,7 @@ collect: function [
767751
/into "Insert into a buffer instead (returns position after insert)"
768752
collected [series!] "The buffer series (modified)"
769753
][
770-
keep: func [v /only][either only [append/only collected v][append collected v] v]
754+
keep: func [v /only][append/:only collected v v]
771755

772756
unless collected [collected: make block! 16]
773757
parse body rule: [ ;-- selective binding (needs BIND/ONLY support)
@@ -937,9 +921,9 @@ read-thru: function [
937921
][
938922
path: path-thru url
939923
either all [not update exists? path] [
940-
data: either binary [read/binary path][read path]
924+
data: read/:binary path
941925
][
942-
data: either binary [read/binary url][read url]
926+
data: read/:binary url
943927
attempt [write/binary path data]
944928
]
945929
data
@@ -955,7 +939,7 @@ load-thru: function [
955939
path: path-thru url
956940
if all [not update exists? path][url: path]
957941
file: either as [load/as url type][load url]
958-
if url? url [attempt [either as [save/as path file type][save path file]]]
942+
if url? url [attempt [save/:as path file type]]
959943
file
960944
]
961945

@@ -964,7 +948,7 @@ do-thru: function [
964948
url [url!] "Remote file address"
965949
/update "Force a cache update"
966950
][
967-
do either update [load-thru/update url][load-thru url]
951+
do load-thru/:update url
968952
]
969953

970954
cos: func [

0 commit comments

Comments
 (0)