[REBOL] Re: On mutability and sameness
From: larry:ecotope at: 5-Jun-2001 16:51
Hi Joel
You pose some interesting examples. I agree the implementation of the date
and time datatypes in REBOL are a bit irregular. Just a couple of quick
comments. You wrote:
> Yes, so perhaps /DATE does an implicit copy? How can we tell?
>
> >> b/time/hour: 9 == 9
> >> b == 6-Jun-2001/8:31:47-5:00
>
> So, "second-level" mutability does not apply? What about
> "first-level mutability"?
>
> >> b/hour: 9 ** Script Error: Invalid path value: hour
> ** Where: halt-view
> ** Near: b/hour: 9
> >> b/hour ** Script Error: Invalid path value: hour
> ** Where: halt-view
> ** Near: b/hour
>
> Hmmm. There is no first-class access to the time fields of a
> date.
>
> >> b/time/hour == 8
> >> c/time/hour ** Script Error: Cannot use path on none!
> value
> ** Where: halt-view
> ** Near: c/time/hour
> >> type? b == date!
> >> type? c == date!
> >> b/time
> == 8:31:47
> >> c/time
> == none
Consider this:
>> d: make date! [5 6 2001 19:23:15 -7:0]
== 5-Jun-2001/19:23:15-7:00
So a date can be made from a block containing 3 integers for day, month and
year, consecutively followed by 2 times, the time of day and the time-zone
offset.
>> t: make time! [10 23 17]
== 10:23:17
So a time can be made from a block of 3 integers for hour minute second,
consecutively.
These two things can be combined to deal with the full form of date which
includes time and time-zone.
>> d: poke d 4 poke pick d 4 1 9
== 5-Jun-2001/9:23:15-7:00
>>
or
>> poke d 4 poke d/4 1 10
== 5-Jun-2001/10:23:15-7:00
The individual time fields can be accessed and modified with pick and poke,
but these access functions, including poke (this differs from poke used on
series), return a value rather than modifying the original date, so we have
to reassign the var name.
Regards
-Larry