Suggesting a syntax for wraping overload set

51 views
Skip to first unread message

Zhihao Yuan

unread,
Oct 19, 2016, 6:01:12 PM10/19/16
to std-pr...@isocpp.org
I gave the reason why I against using the following syntax

[] funcname

to lift an overload set / operators into a lambda expression:
the captures are never used. Moreover, they may end up
being misleading. Consider the member access support in
p01192r2 prefixed with []:

[] obj.data

So this lambda captures obj or not?

So I try to go back to the origin of the problem we are solving:
we have various kinds of things which are close to callable,
just not first-class. And the transformation we are doing are
merely from

f

to

\x -> f(x)

In lambda calculus, we call this transformation Eta-expansion
(η-reduction for the reserve process, and η-conversion for
either -- adding or dropping an abstraction).

Scala is a language that I know for using the term Eta-expansion
in its language spec, because they face a similar problem --
methods are not functions.

And my suggestion for C++ is very simple:

etaexpr(funcname)
etaexpr(std::iota)
etaexpr(<)

etc. A new keyword, etaexpr, seems never seen according to
google and github, reads "Eta (wrapped/expanded) expression",
and means "to wrap a lexical lookup / operator / member access
into a lambda".

--
Zhihao Yuan, ID lichray
The best way to predict the future is to invent it.
___________________________________________________
4BSD -- http://blog.miator.net/
Reply all
Reply to author
Forward
0 new messages