Comments on: REDUCE/no-set
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.
|