REBOL 3.0

Comments on: REDUCE/no-set

Carl Sassenrath, CTO
REBOL Technologies
30-Aug-2007 4:08 GMT

Article #0101
Main page || Index || Prior Article [0100] || Next Article [0102] || 7 Comments || Send feedback

Here is a frequent pattern: you have a block of set-words and value expressions. You want to reduce the expressions, but leave the set-words as is.

For example, you might have:

spec: [ 
    size: xy + 100x200
    offset: parent / 2
    text: join base specific
]

Then you want to do something like:

a-spec: make map! spec

or perhaps:

a-gob: make gob! spec

But, that is a problem, because you cannot easily reduce the block without the set-words getting set.

Fortunately, along comes REDUCE/no-set. This refinement to REDUCE prevents the set operation for set-words within the block.

Using it on the spec block above, you would see something like:

>> probe reduce/no-set spec
== [
    size: 240x480
    offset: 100x200
    text: "App Prefs"
]

7 Comments

Comments:

Henrik
30-Aug-2007 5:42:32
I have practically never needed to reduce a set-word inside a block, so this is a deeply welcome feature. Thanks. :-)
Goldevil
30-Aug-2007 8:49:31
Very interesting to generate VID scripts at run time. Very good idea.
maarten
31-Aug-2007 2:13:10
I think I use compose in those cases....
Robert
31-Aug-2007 5:41:38
My problem with COMPOSE in such cases is, as soon as you calculate something with parens it's a bit cumbersome to get done right.
RobertS
1-Sep-2007 8:34:06
Should the /only refinement be renamed if this refinement is added? /no-set /no-func /no-path with /only left for backwards compat but marked deprecated?
Chris
21-Dec-2007 11:10:06
It'd be nice if this were default behaviour of reduce, with reduce/all as the all-powerful override. Yes, it'd not be compatible, but in this case merited on the benefits to the language?
Pier Johnson
20-Jan-2008 18:59:09
Sweet.

This gives the smarter programmer dynamic (run-time) data setting.

Post a Comment:

You can post a comment here. Keep it on-topic.

Name:

Blog id:

R3-0101


Comment:


 Note: HTML tags allowed for: b i u li ol ul font span div a p br pre tt blockquote
 
 

This is a technical blog related to the above topic. We reserve the right to remove comments that are off-topic, irrelevant links, advertisements, spams, personal attacks, politics, religion, etc.

REBOL 3.0
Updated 20-Nov-2017 - Edit - Copyright REBOL Technologies - REBOL.net