Hi Elan,

Thanks for the comments, and thanks for the term "type designator". I wasn't
sure what to call it. But I'm not sure we understand each other yet. I
glossed over a few too many things.

>you report that
>
>>>> third :f
>>== [x [decimal!]]
>>>> first second third :f
>>== decimal!
>>>> type? first second third :f
>>== datatype!
>
>in other words, the type designator we provided when we constructed the
>function
>a) continues to be a type designator as demonstrated by
>>>> type? first second third :f
>>== datatype!
>b) it is the type designator we originally used to construct the function
>>>> first second third :f
>>== decimal!

The original type designator, as I tried to point out before, was a word,
not a datatype.

This time let's store the specification of F in a block before we make F.

>> spec: [x [integer!]]
== [x [integer!]]
>> first second spec
== integer!
>> type? first second spec
== word!

So the type designator here is a word.

>> f: func spec [x * x]
>> third :f
== [x [integer!]]
>> first second third :f
== integer!
>> type? first second third :f
== datatype!

Now the type designator in the "compiled" F is a datatype, though it looks
the same. And notice that the type designator in the original spec block
is still a word:

>> type? first second spec
== word!

Now this is why I was so interested in your mention of past behavior of
REBOL. If we do the same thing with

>> system/version
== 2.0.4.3.1

We see basically the same thing happening:

>> spec: [x [integer!]]
== [x [integer!]]
>> type? probe first second spec
integer!
== word!
>> f: func spec [x * x]
>> third :f
== [x [integer!]]
>> type? probe first second third :f
integer!
== datatype!

But this is where the bug was:

>> type? probe first second spec
integer!
== datatype!

The spec block used in the construction of F was altered, so if we reuse it:

>> ff: func spec [x * x]
>> source ff
ff: func [x [datatype!]][x * x]

We get a different function than the first one - in this case one that
will give an error for any input. This is exactly the result we get with
the current version of REBOL doing:

>> ff: func third :f second :f
>> source ff
ff: func [x [datatype!]][x * x]

So one bug was fixed, presumably by having MAKE deep copy the original spec
block before using it to construct the function. But you still can't use the
spec block integrated into the function in constructing yet another function,
unless of course you want a function that requires datatypes as arguments.

I don't think this qualifies as a serious problem, but once I did try to
use THIRD :F in this way, saw that it didn't work, and got curious. That's
why I called it a "puzzle".

Now I've gotten myself all steamed up about words and datatypes again ;-)
so I think I'll start a new message and go over yet again what for me is the
most important issue regarding datatypes.

Your comments will be as ever most appreciated.

Thanks,
Eric

Reply via email to