argument ordering (was: Re: Priority Queues, or lack thereof)
Okasaki, C. DR EECS
Christopher.Okasaki at usma.edu
Mon Aug 22 09:10:53 EDT 2005
David Roundy wrote:
>> This style supports multiple operations nicely, especially with
combined
>> with the $ operator. For example, to insert 3 elements into a set,
you
>> can say
>> insert 1 $ insert 2 $ insert 3 $ someSet
>> (the last $ is optional). With the other argument ordering, you
would
>> say
>> insert (insert (insert someSet 3) 2) 1
>
> With this ordering, couldn't one simply write
>
> someSet `insert` 3 `insert` 2 `insert` 1
>
> ?
Sure, although I'll admit that I have an aversion to the backquote style
of infix operators.
The bigger problem with this style is what to do about non-binary
operations. For example, insert for a dictionary takes three arguments.
So you could write
insert 1 a $ insert 2 b $ insert 3 c dict
but not
dict `insert` 1 a `insert` 2 b `insert' 3 c
Of course, you could potentially package some arguments in a tuple
dict `insert` (1,a) `insert` (2,b) `insert` (3,c)
but having some arguments in tuples has its own problems.
-- Chris
More information about the Libraries
mailing list