Boost logo

Boost :

From: Jaakko Jarvi (jarvi_at_[hidden])
Date: 2006-04-13 12:21:29


On Apr 13, 2006, at 10:05 AM, Peter Dimov wrote:

> Jaakko Jarvi wrote:
>> On Apr 12, 2006, at 4:18 PM, Peter Dimov wrote:
>>
>>> I'd prefer to not be forced to spell the type of the arguments:
>>>
>>> inline bool less( x, y ) { return x < y; }
>>>
>>> (and live with the ambiguities when x is a type in an outer scope)
>>> but even
>>> with explicit typing as in N1958 it's much better than nothing. :-)
>>
>> The syntactic trouble (which I believe Peter is referring to with the
>> comment on ambiguities)
>> is that in a normal function parameter list one can leave out the
>> parameter name, here we would
>> be leaving out the parameter type. I think that is fine, but I'd thus
>> rather make lambdas
>> look different so that there is no confusion of what kind of
>> parameter list we are dealing with.
>>
>> (e.g. with the syntax <>(x, y) { return x < y; } )
>>
>> Flagging an ambiguity in the case that the parameter name would be a
>> type in an outer scope seems quite brittle.
>
> But I should also note that there are three cases:
>
> 1. Lambdas require explicit argument types, as ordinary functions do;
> 2. Lambdas do not have explicit argument types (as in the above
> examples);
> 3. Lambdas allow explicit argument types but do not require them.
>
> The ambiguity arises only in (3). (1) and (2) don't have this problem.

Yes, very true.
My concern with (2) if the syntax of lambdas is practically the same
as normal functions is
having two kind of function definitions (local and global) with
seemingly the same syntax, but
yet with different behavior.

There is another related problem on which discussion would be welcomed.
Assuming no types need to be provided for the parameter types, what
is the parameter passing mode?

It seems that && makes the most sense, but we haven't found a good
syntax to override this.
OTOH, we don't have strong arguments why the parameter passing mode
should be allowed to be overridden.

Best, Jaakko


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk