On 12-04-13 11:07 PM, Kobi Lurie wrote:

> one is reverse application.
> it's actually logical and might simplify things.
> (similar to extension methods in c#)
> there are no classes, but a syntax like: obj.method(b,c) still exists.
> from what I could tell, the function is really method(obj,b,c), and the
> previous syntax gets translated to it. which is just nicer for the
> programmers, minimizing parentheses.

This is what our typeclasses (impls and ifaces) currently do.

> another thing is that instead of passing arguments, you pass just one
> (anonymous) record. the record is the arguments.

We actually had quite an argument with one of the Felix authors about
this. This was not, back then, a terribly realistic option during that
conversation (argument modes were still the primary way we were doing
safe references, which are not first class types). But it's conceivably
something we could look into if we get the argument-passing logic down
to "always by-value and use region pointers for safe references" (which
is where we're going). There remain some hitches:

 - Our syntax isn't quite compatible with the idea; records have to be
   brace-parenthesized and tuples given round parentheses. They'd need
   reform, and the syntax is already pretty crowded.

 - We'd have to decide the rules surrounding keyword mismatches, partial
   provision of keywords, argument permutation, and function types.

 - Our records are order-sensitive, to be C-structure compatible.
   Keyword arguments are usually argued-for (as you are doing here) as
   a way to make function arguments order-insensitive. We'd need to
   decide whether we wanted order to matter or not.

 - Argument-passing tends to work best when you can pass stuff in
   registers, not require the arguments to be spilled to memory and
   addressable as a contiguous slab. So we'd want to be careful not to
   require the "arguments structure" to be _actually_ addressable as a
   structure at any point. Rather, calling f(x) would be some kind of
   semantic sugar for `f(x.a, x.b, x.c)`, making separate copies for
   the sake of passing.

So .. I can see a possibility here, but it'd be a complicated set of
issues to work through. Would need some serious design work. I've never
been intrinsically opposed to it, just felt that we were constrained by
other choices in the language. At the time, argument modes were
completely prohibitive; now it might be possible, but is still not
entirely straightforward.

-Graydon
_______________________________________________
Rust-dev mailing list
Rust-dev@mozilla.org
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to