metaeducation / rebol-issues

6 stars 1 forks source link

Make EXCLUDE modify its argument, rename INTERSECT=>INTERSECTION #2222

Open rebolbot opened 9 years ago

rebolbot commented 9 years ago

Submitted by: fork

I wanted to remove some items from a set, and realized I didn't know if EXCLUDE modified its argument or not. It sounds transitive, and transitive words like that tend to modify. Consider

>> head insert [a b c] [d e f]
== [d e f a b c]

But exclude does not modify:

>> foo: [a b c d e f]         
== [a b c d e f]
>> exclude foo [b e f]
== [a c d]
>> foo
== [a b c d e f]

If the word was EXCLUSION it wouldn't seem as odd. Or even more clear, EXCLUSION-OF.

INTERSECT has the same problem, and could similarly be solved with INTERSECTION or INTERSECTION-OF. Then INTERSECT could modify.

In trying to complete the set we'd wind up with:

INTERSECTION-OF, UNION-OF, EXCLUSION-OF, DIFFERENCE-OF

As parallels to their transitive forms:

INTERSECT, UNITE, EXCLUDE, DIFFERENTIATE (?)

However, differentiate sounds like Calculus, and I can't think of a better word. And really, having both sets is probably excessive.

The simplest solution would seem to be to make EXCLUDE the only verb form, and if you want a copying version make the copy yourself (as one has to do with INSERT and APPEND and other operations). Then just rename INTERSECT to INTERSECTION and call it done.

CC - Data [ Version: r3 master Type: Wish Platform: All Category: Unspecified Reproduce: Always Fixed-in:none ]

ladislav commented 8 years ago

"I didn't know if exclude modified its argument or not" - modifying functions must document the arguments they modify, see, e.g., help insert.

ladislav commented 8 years ago

See also add, which does not modify either. The general naming rule Carl used was that all these functions shall use verbs as names.

ladislav commented 8 years ago

I prefer to keep these functions/function names unchanged.