[EMAIL PROTECTED] wrote:
> 
> datatype!, object!, port!, refinement!, none!, logic!, integer!,
> decimal!, money!, time!, date!, char!, tuple!, bitset!, string!,
> issue!, binary!, file!, email!, url!, tag!, block!, hash!, list!
> 
> All the values of these types evaluate returning themself.
> 

And some of them have some curious behavior!  In the case of 

    >> mytime: now/time
    == 20:32:33
    >> mytime/hour
    == 20
    >> mytime/minute
    == 32
    >> mytime/minute
    == 32
    >> mytime/minute: 35
    == 20:35:33
    >> mytime
    == 20:32:33

and

    >> mydate: now/date
    == 2-Jan-2000
    >> mydate/day
    == 2
    >> mydate/month
    == 1
    >> mydate/year
    == 2000
    >> mydate/day: 3
    == 3-Jan-2000
    >> mydate
    == 2-Jan-2000

it would appear that we have composite values that are immutable,
in the sense that they possess internal structure, but an attempt
to change a component of that structure returns a new value of the
same type, without modifying the original.  This is, of course, in
contrast to the mutability of strings.

Incidentally, this also puts an interesting spin on the 'same?
function.  As the internals of a time! or date! can't be altered,
it is "safe" to consider any two equal time or date values to be
the same:

    >> mydate
    == 2-Jan-2000
    >> otherdate: make date! reduce [1 + 1 2 - 1 2 * 2 * 500]
    == 2-Jan-2000
    >> same? mydate otherdate
    == true

    >> mytime
    == 20:32:33
    >> othertime: make time! reduce [4 * 5 2 * 8 * (1 + 1) 3 * 11]
    == 20:32:33
    >> same? mytime othertime
    == true

-jn-

Reply via email to