From: Jussi Piitulainen on
Lie Ryan writes:

> Whether C or <insert some language> considers function call an
> operator or not, it doesn't matter. We're not talking about a real
> language which always have syntactical limitations artificially
> imposed by the language design or practicality of implementation or
> taste.

Even if you are not, some of us have been. "The ternary operator"
refers specifically to the pair of characters ?: used in C and Java
and so on. And I wish to pollute that terminological space so that
people would then revert to a more proper name for that construct. I
propose to do this by getting another "ternary operator" added to
these languages. This may or may not be realistic.
From: bart.c on
"Lie Ryan" <lie.1296(a)gmail.com> wrote in message
news:4beaf724$1(a)dnews.tpgi.com.au...
> On 05/12/10 22:24, bart.c wrote:

>> Operators and functions tend to be different, although functions might be
>> used to implement operators.
>
> Conceptually, there is no difference between function and operator.
> Their difference is just syntactical.

In my language projects, the difference is rather more than just syntax (I
wish it was merely syntax..).

Even if you mostly forget syntax, as in Lisp-like languages that have
minimalist syntax, you quickly find you need all sorts of special properties
in order to do things taken for granted in a traditional language.

(For example, how *do* you add two values of mixed type? Having operators
and functions as separate concepts is useful here, because it's easy to just
say that operators are 'special'.

But yes, the difference is a little artificial, and with a language of high
enough level, you can have the luxury of making them interchangeable.)

--
bartc

From: Ben Bacarisse on
Lie Ryan <lie.1296(a)gmail.com> writes:

> On 05/12/10 23:28, Ben Bacarisse wrote:
>> Lie Ryan <lie.1296(a)gmail.com> writes:
>>
>>> On 05/10/10 18:12, Jussi Piitulainen wrote:
>>>>>>>> Anything vaguely usable with three operands would do. Median of
>>>>>>>> three numbers. Majority vote of three booleans.
>>>>>>
>>>>>> Many of these are just special cases of N-operand operators. The
>>>>>> challenge is an operator syntax that allows an arbitrary number of
>>>>>> operands (and which doesn't look like a single operand which happens
>>>>>> to be a list, although that is another way of doing it).
>>>> Yes, I have trouble thinking up any naturally ternary operations. As
>>>> soon as the notation has brackets and a comma in it, it is natural to
>>>> extend the number of operands arbitrarily. We do zero, one, two, many.
>>>
>>> Think again: function call is an N-ary operator
>>
>> Not always. Some languages consider it to be binary (Haskell, for
>> example) and that works out quite neatly.
>
> in Haskell, function call is binary, which is a kind of N-ary. So the
> statement still hold.

You mean because N might equal 2 in the term N-ary? If so a smiley
would have helped! If not I don't know what you mean and a definition
might be needed. The context suggests that N-ary is being used to
describe operators that don't have a single 'arity'.

--
Ben.
From: Lie Ryan on
On 05/13/10 09:27, bart.c wrote:
> "Lie Ryan" <lie.1296(a)gmail.com> wrote in message
> news:4beaf724$1(a)dnews.tpgi.com.au...
>> On 05/12/10 22:24, bart.c wrote:
>
>>> Operators and functions tend to be different, although functions
>>> might be
>>> used to implement operators.
>>
>> Conceptually, there is no difference between function and operator.
>> Their difference is just syntactical.
>
> In my language projects, the difference is rather more than just syntax (I
> wish it was merely syntax..).
>
> Even if you mostly forget syntax, as in Lisp-like languages that have
> minimalist syntax, you quickly find you need all sorts of special
> properties
> in order to do things taken for granted in a traditional language.

Forget list, forget real-life language, forget language with minimal
syntax. Thinking in pure mathematical, there is no sense of
distinguishing them (other than syntactical preferences).

> (For example, how *do* you add two values of mixed type? Having operators
> and functions as separate concepts is useful here, because it's easy to
> just say that operators are 'special'.

Well, real-life languages you can overload operators. In mathematics
mixed type operation is simply whatever you defined it to be (e.g.
multiplication between a scalar and a matrix).

> But yes, the difference is a little artificial, and with a language of
> high enough level, you can have the luxury of making them interchangeable.)
From: Lie Ryan on
On 05/13/10 21:14, Ben Bacarisse wrote:
> Lie Ryan <lie.1296(a)gmail.com> writes:
>
>> On 05/12/10 23:28, Ben Bacarisse wrote:
>>> Lie Ryan <lie.1296(a)gmail.com> writes:
>>>
>>>> On 05/10/10 18:12, Jussi Piitulainen wrote:
>>>>>>>>> Anything vaguely usable with three operands would do. Median of
>>>>>>>>> three numbers. Majority vote of three booleans.
>>>>>>>
>>>>>>> Many of these are just special cases of N-operand operators. The
>>>>>>> challenge is an operator syntax that allows an arbitrary number of
>>>>>>> operands (and which doesn't look like a single operand which happens
>>>>>>> to be a list, although that is another way of doing it).
>>>>> Yes, I have trouble thinking up any naturally ternary operations. As
>>>>> soon as the notation has brackets and a comma in it, it is natural to
>>>>> extend the number of operands arbitrarily. We do zero, one, two, many.
>>>>
>>>> Think again: function call is an N-ary operator
>>>
>>> Not always. Some languages consider it to be binary (Haskell, for
>>> example) and that works out quite neatly.
>>
>> in Haskell, function call is binary, which is a kind of N-ary. So the
>> statement still hold.

s/binary/unary

> You mean because N might equal 2 in the term N-ary? If so a smiley
> would have helped! If not I don't know what you mean and a definition
> might be needed. The context suggests that N-ary is being used to
> describe operators that don't have a single 'arity'.
>

Why would smiley helps? That statement is just as serious as it can be.
In pure (functional) language, a function that takes 1 argument is 1-ary
operator; a function that takes 2 argument is 2-ary operator, and so on.
They can be generalized as "a function that takes N argument is N-ary
operator". In another post, Pascal J.B pointed out that a 'constant' can
conceptually be thought as a function that takes no argument i.e. a
constant is a function with zero argument is 0-arity operator; so the
statement holds true even when N == 0.

The fact that the underlying language, in this case Haskell, restricts
function call to take only a single argument doesn't invalidate the
statement.

In impure language, all functions just takes, as Pascal also pointed
out, a hidden 'time' argument and a some extra layers of hidden arity.
If we can enumerate all these hidden arguments (which in practice may
not always be doable); then the statement holds true for impure
languages as well.