Hi Ladislav,
You're system of functions is quite amazing. I'm trying to digest
what you're aiming at, little by little.
I assume you meant:
register 'minus [integer! complex!] [] [
make complex [
re: a - b/re
im: - b/im ; not im: b/im
]
]
I tried to register another combination of types:
register 'minus [complex! complex!][][
make complex [
re: a/re - b/re
im: a/im - b/im
]
]
And got this:
>> print mold _minus
make object! [
type: polymorphic!
args: [a b]
signatures: [integer! complex! complex! complex!]
implementations: [
func [a [any-type!] b [any-type!] /local][
make complex [re: a - b/re im: b/im] ]
func [a [any-type!] b [any-type!] /local][
make complex [re: a/re - b/re im: a/im - b/im] ]
]
]
Shouldn't the signatures look more like:
signatures: [[integer! complex!] [complex! complex!]]
? Because when you look for [complex! complex!] in the signatures
(that's what the function MINUS does) this happens:
>> find _minus/signatures [complex! complex!]
== [complex! complex! complex!]
That's going to lead to problems. I think each signature should be
within a nested block, and you should be using FIND/ONLY to look
for it.
I'm also a little puzzled by your latest PIF:
>pif: func [[throw]
> {
> polymorphic if
> lazy evaluation, minimum checking, no default
> compatible with:
> computed blocks
> Return
> Exit
> Break
> non-logic conditions
> }
> args [block!]
>] [
> if not unset? first args: do/next args [
> either first args [
> either block? first args: do/next second args [
> do first args
> ] [
> first args
> ]
> ] [
> pif second do/next second args
> ]
> ]
>]
>> command: [print]
== [print]
>> pif [
false do append copy command "hello"
true do append copy command "goodbye"]
hello
goodbye
Is this what you intended?
Have a good one,
Eric