tags:

views:

38

answers:

2
>> example: make object! [
[        var1: 10
[        var2: var1 + 10
[        var3: now/time
[        set-time: does [var3: now/time]
[        calculate: func [value] [
[                var1: value
[                var2: value + 10
[            ]
[    ]
>>
>> example2: make object! third example
** Script Error: none is missing its value argument
** Near: calculate: func [value][
    var1: value
    var2: value + 10
]
>>

How to prevent evaluation of third example ?

+1  A: 

Best way is probably to use construct/with -- it creates an object based on an existing one.

To make an object based on the example object plus an extra field:

example2: construct/with [extra-field: 999] example

or to make one with just the same fields

example2: construct/with [] example
Sunanda
Great tips I didn't know that !
Rebol Tutorial
+1  A: 

You could also take advantage of Rebol's object prototyping:

example2: make example []

or with additional fields

example3: make example [      
  var4: now/date
  set-date: does [var4: now/date]
]

or replacing fields

example4: make example [
  calculate: func [value] [
    var1: value
    var2: value + 20
  ]
]
Peter W A Wood