[REBOL] Re: Bug! in assignment to date! values with stacked set-path values
From: lmecir:mbox:vol:cz at: 15-Nov-2002 8:07
Hi Romano,
> Yes, but func are already fetched twice, why not path?
(-: It looks to me, that we always want the opposite of the actual
implementation! :-)
I think (Praetera censeo), that functions should be fetched just once and
that
a: func [x] [type? :x 1]
b: func [x] [type? :x 2]
a a: :b
Should yield 1 (Carthaginem esse delendam).
Joel can call my request "the principle of the least surprise", but there is
another reason to change the current behaviour: we can avoid some nasty
errors/interpreter crashes/bugs this way.
OTOH, set-paths are different animals.
a: "1"
a/1: (a: "3" #"2")
a
Here everybody is surprised, that the last operation, which is the path-set
somewhat magically "occurs" (at least partially) before the paren!
evaluation, which, again, seems to violate "the principle of the least
surprise".
Nevertheless, paths can be evaluated like above and it makes perfect sense
to me:
a: make object! [f: does [a: make object! [f: does [2]] 1]]
a/f ; == 1
This makes perfect sense to me, although:
probe a
make object! [
f: func [][2]
]
Another thing I want to mention is, that while
a: "12"
a/1: #"3" ; == "32"
the same operation used for dates yields:
a: now
a/day: 1 ; == 1
, which doesn't look unified.
-L