REBOL Technologies

Cascaded Variable Sets From Paths and Pokes

Carl Sassenrath, CTO
REBOL Technologies
17-Jun-2005 2:52 GMT

Article #0177
Main page || Index || Prior Article [0176] || Next Article [0178] || Post Comments || Send feedback

Ok, so this is important: In REBOL you can write a cascaded assignment (set) like this:

a: b: 1

This sets both a and b to 1.

Similarly, if a and b are series:

a: [1 2 3]
b: [4 5 6]

then this should be valid:

c: a/1: b/1: 0

where the results are:

a = [0 2 3]
b = [0 5 6]
c = 0

This is a natural result that is found in most languages. In C code you can write:

c = a[1] = b[2] = 0;

In REBOL, cascading should work for any datatype. The results of a path-set should always return the argument value (not the target value). So, if I write:

a: 1-Jun-2000
b: 10-May-2005
c: a/time: b/time: 10:00


a = 1-Jun-2000/10:00
b = 10-May-2005/10:00
c = 10:00

Behind the scenes, the set-path action translates directly into a poke action. This equality is true:

(a/1: 0) == (poke a 1 0)

So, that means that the result of poke returns the argument, not the target. In the code:

a: [1 2 3]
b: poke a 1 0

This is the result:

a = [0 2 3]
b = 0

Unfortunately, that breaks some scripts, and the 1.3.0 release has done just that. It happened as the result of many path improvements that were made in 1.3.

What should we do? We can either deal with it and fix those scripts, or... if that is too painful... it may be possible to separate the set-path result from the poke result. In other words allow:

(a/1: 0) <> (poke a 1 0)

Discuss it with your fellow REBOLs, and let me know your thoughts. This is one of those tough issues, so we need to debate it.

Post Comments

Updated 15-Nov-2017   -   Copyright Carl Sassenrath   -   WWW.REBOL.COM   -   Edit   -   Blogger Source Code