help
if you do use form:
as a name.>> form: [size 800x600 backdrop coal]
== [size 800x600 backdrop coal]
>> view form
>> help system
*** Script Error: pad does not allow word! for its n argument
*** Where: pad
*** Stack: help help-string pad
>> help either
*** Script Error: uppercase does not allow block! for its string argument
*** Where: uppercase
*** Stack: help help-string
>> a: 1
== 1
>> f: func [x][x + a]
== func [x][x + a]
>> f 3
== 4
>> a: 10
== 10
>> f 3
== 13
form
protect
, but right now you have to be careful.
Should we start a dialogue about dialogs?
https://gist.github.com/greggirwin/9cd640ca42bdfd56c5ff4432c4765d2c?ts=4
Hi all! Is there a function in Red which would be used like this:
update obj ['foo 1 'bar/baz 2]
which would be equivalent to:
do [ obj/foo: 1 obj/bar/baz: 2 obj ]
? Where obj is an object!. If not, is it possible to define such function? (Macro would not work for me here.) I think this is maybe something like what they call "lenses" in Haskell etc, but I'm not sure, never used Haskell?
@akavel I guess I don't really understand what you are looking for as most people would simply assemble a block and reduce it.
You could do this but at the expense of creating a new object:
>> o: make object! [a: 0 b: make object! [c: 0]]
== make object! [
a: 0
b: make object! [
c: 0
]
]
>> o: make o [a: 1 b/c: 2]
== make object! [
a: 1
b: make object! [
c: 2
]
]
>> probe object collect [foreach accessor system/catalog/accessors/date! [keep to set-word! accessor] keep none]
make object! [
date: none
year: none
month: none
day: none
zone: none
time: none
hour: none
minute: none
second: none
weekday: none
yearday: none
timezone: none
week: none
isoweek: none
julian: none
]
>> obj: make object! [date: now map: #(a: 1 b: 2)]
== make object! [
date: 9-Nov-2017/16:35:18+01:00
map: #(
a: 1
b: 2
)
]
>> diff: [date/weekday: 1 map/a: 3]
== [date/weekday: 1 map/a: 3]
>> effect: collect [foreach . diff [keep/only case [set-path? . [make set-path! compose [obj (to-block .)]] true [.]]]]
== [obj/date/weekday: 1 obj/map/a: 3]
>> reduce effect
== [1 3]
>> obj
== make object! [
date: 6-Nov-2017/16:35:18+01:00
map: #(
a: 3
b: 2
)
]
keep/only
? typing ? collect
in console only provides help about raw keep
, no word about refinements...
>> obj: object [date: now map: #(a: 1 b: 2)]
== make object! [
date: 9-Nov-2017/21:01:50+05:00
map: #(
a: 1
b: 2
)
]
>> diff: [date/weekday: 1 map/a: 3]
== [date/weekday: 1 map/a: 3]
>> do bind diff obj
== 3
>> obj
== make object! [
date: 6-Nov-2017/21:01:50+05:00
map: #(
a: 3
b: 2
)
]