Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2006-04-13 11:05:19


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.


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