On 12-06-11 3:02 PM, Niko Matsakis wrote:
On 6/10/12 11:30 AM, Patrick Walton wrote:
I like this. The only concern, as a comment pointed out, is that "*"
might be slightly confusing; maybe "ref" is better.

Yes, gasche stated that using a keyword like `copy` and a sigil like `*`
seemed inconsistent. I can see that, I suppose, though I think that
using a keyword like `ref` that appears nowhere else in the language
seems even more inconsistent, not to mention heavyweight (who wants to
write `let (ref x, ref y) = pair`?).

I assume that Cyclone's reasoning with `*x` was that—like other
patterns—it's the inverse of what you would do to create the value.

It's not the inverse; the expression and pattern forms are _the same_. That is, to eliminate a record {x:foo} we write a pattern {x:foo} and recover foo. To match a @foo expression, we write the pattern @foo. The operational inverse of @ is * and {x:foo} is .x. But we're not talking inverses.

What you're doing is proposing -- a bit of a stretch -- that a user's intuition is that for any expression E, they "effectively" wrote *P for some imaginary pointer P, and they can recover that pointer by matching against the written-the-same-way pattern *P. Which is ... mathematically tidy, certainly hits the correctness note, but it feels to me like a bit of a footgun. Somehow no matter how many times I read it, when I see:

  let *x = foo;

I expect this means that foo is a pointer and x is bound to the pointee. I know that makes no sense. I'll try to inhibit that reflex and see how it goes.

I'm also concerned about the perf implication of copying by default. I guess it might be ok if the implicit-copies warning is turned on by default. Which we'll get to. It might slow things down quite a bit until that time...

Still, this is important work and these objections are more like uneasy feelings than fixes for same. I'd say go ahead with it and see how it fares. Worst case we have to revisit.

-Graydon
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to