Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A "Design FAQ" document #4047

Closed
bstrie opened this issue Nov 27, 2012 · 52 comments
Closed

A "Design FAQ" document #4047

bstrie opened this issue Nov 27, 2012 · 52 comments

Comments

@bstrie
Copy link
Contributor

bstrie commented Nov 27, 2012

In the vein of the Project FAQ and the Language FAQ.

In addition to being really interesting, this would save a lot of time and divert a lot of potential questions in the long run. Some topics to discuss:

  • Why was typestate removed?
  • Why are some types nominal instead of structural?
  • Why do I have to declare impls in the same crate as a type or trait?
  • Why is trait inheritance the only means of inheritance?
  • Why doesn't Rust do tail-call optimization?
    (see e.g. rust-dev post.)

Explanations should be technical and include code examples wherever possible.

Some of the questions of this nature overlap with the latter half of the Language FAQ, but not all, e.g. "Can Rust code call C code?" and "What is the difference between a managed pointer and an owned pointer?" do not belong. The document should focus on large-scale design decisions and tradeoffs; think "Why split stacks?" rather than "How do split stacks work?".

If you think of good questions, add them in the comments here. There are probably a lot of ripe areas for explanation, especially with regard to mutability and regions.

@brson
Copy link
Contributor

brson commented Nov 27, 2012

The manual has a related (and empty) section: http://dl.rust-lang.org/doc/0.4/rust.html#appendix-rationales-and-design-tradeoffs

@bstrie
Copy link
Contributor Author

bstrie commented Nov 29, 2012

Why are &str, @str, ~str, &[], @[], and ~[] treated differently from &T, @T, and ~T?

@bstrie
Copy link
Contributor Author

bstrie commented Dec 5, 2012

Why are early returns disallowed within closures?

@bstrie
Copy link
Contributor Author

bstrie commented Dec 7, 2012

Why are separate do and for constructs required?

@bstrie
Copy link
Contributor Author

bstrie commented Dec 11, 2012

Why do traits in Rust depart from the design in the original traits paper?

@bstrie
Copy link
Contributor Author

bstrie commented Jan 1, 2013

Why must imports be qualified relative to the crate?

@graydon
Copy link
Contributor

graydon commented Jan 2, 2013

These are great, please keep them coming

@catamorphism
Copy link
Contributor

"What does const mean (and why)?" should be in there too, though I know we're thinking about renaming it (at least).

@bstrie
Copy link
Contributor Author

bstrie commented Jan 17, 2013

Why feature conditions rather than exceptions?

@jruderman
Copy link
Contributor

Why so many pointer types? Why not rely on escape analysis instead?

Answered at:

http://www.reddit.com/r/programming/comments/17hqg4/a_little_bit_rusty_practical_approach_on_rust/c85r1nc

@bstrie
Copy link
Contributor Author

bstrie commented Jan 31, 2013

Why is the .times() method no longer defined on signed integers? (discussion on the specifics of integer literal inference)

@bstrie
Copy link
Contributor Author

bstrie commented Feb 21, 2013

Why do borrow checks on @mut pointers happen at runtime?

@acertain
Copy link

Why are there no exceptions?

@bstrie
Copy link
Contributor Author

bstrie commented Apr 2, 2013

Why is name resolution such an intractably hard problem?

<@pcwalton> I know of no other static language with declarative imports
            that allows (a) reexports; (b) glob import; (c) mutual
            recursion everywhere; (d) nested modules; (e) two namespaces
<@pcwalton> java doesn't have reexports, Go doesn't have nested modules
            or reexports, C# doesn't have reexports I don't think, C++
            doesn't have reexports or mutual recursion everywhere, maybe
            D...
<@pcwalton> ML and Haskell don't have mutual recursion everywhere and
            don't have reexports
<@pcwalton> mutually recursive modules too
<@pcwalton> most languages do not have mutually recursive modules
< bstrie> pcwalton: so what you're saying is that rust has once again
          failed to be unoriginal :)
<@pcwalton> well, as you said, Python
<@pcwalton> but Rust is trying to achieve Python's module system's
            expressive power in a static system
  jld tries to remember how the various Scheme module systems work
<@pcwalton> turns out that's pretty hard :)
<@pcwalton> jld: no mutual recursion
<@pcwalton> btw, ES6 hit the exact same problems we did
<@pcwalton> and had to pare down their module system as a result
<@pcwalton> anyway none of this is an excuse, we should make it easier to
            use
<@pcwalton> but I'm just saying it's not that easy...

@brson
Copy link
Contributor

brson commented Apr 30, 2013

Here's a summary about dynamically sized types https://mail.mozilla.org/pipermail/rust-dev/2013-April/003933.html

@brson
Copy link
Contributor

brson commented Apr 30, 2013

Summary of 'why no exceptions' https://mail.mozilla.org/pipermail/rust-dev/2013-April/003815.html

@catamorphism
Copy link
Contributor

Summary of 'why no purity-in-the-type-system, i.e., why no effect system': https://mail.mozilla.org/pipermail/rust-dev/2013-April/003926.html

@iampiyush
Copy link

document how to make non-utf8 byte vectors with bytes!(…)

e.g.
use of bytes!("hell", 0xc0, 0xca, "o!") instead of bytes!("hell\xc0\xca\o1!")

@brson
Copy link
Contributor

brson commented Jul 30, 2013

@kud1ing
Copy link

kud1ing commented Aug 5, 2013

Why have we mostly moved from internal iterators to external iterators?
https://mail.mozilla.org/pipermail/rust-dev/2013-June/004364.html

@kud1ing
Copy link

kud1ing commented Aug 8, 2013

Why was the runtime ported from C++ to Rust?

@brson
Copy link
Contributor

brson commented Dec 4, 2013

@pnkfelix
Copy link
Member

Why does one need to explicitly pull a trait into scope in order to access that trait's methods on a (separately imported or locally defined) type?

Answer (I think): Because the alternative is name collisions (that could arise much later in the dev cycle). We're just forcing you to resolve those conflicts up front. See also: the wiki

@brson
Copy link
Contributor

brson commented Jan 26, 2014

Why does Rust have two threading implementations?

Why does Rust prefer asynchronous channels?

Why are struct fields public by default?

@brson
Copy link
Contributor

brson commented Jan 27, 2014

Why are ints pointer sized?

@brson
Copy link
Contributor

brson commented Jan 31, 2014

Why such a verbose syntax for mutable locals? (Why not var instead of let mut?)

Some links:

https://mail.mozilla.org/pipermail/rust-dev/2014-January/008364.html
https://mail.mozilla.org/pipermail/rust-dev/2014-January/008319.html
#2643

@brson
Copy link
Contributor

brson commented Feb 22, 2014

Why no TCO (this comes up all the time): https://mail.mozilla.org/pipermail/rust-dev/2013-April/003557.html

@brson
Copy link
Contributor

brson commented Apr 17, 2014

Why do Rust's submodules map to directories and mod.rs the way they do instead of [some other way]?

https://mail.mozilla.org/pipermail/rust-dev/2014-April/009554.html

@bstrie
Copy link
Contributor Author

bstrie commented Apr 30, 2014

Why a dedicated loop keyword?

@brson
Copy link
Contributor

brson commented May 21, 2014

@kud1ing
Copy link

kud1ing commented May 23, 2014

See also #14370

@bstrie
Copy link
Contributor Author

bstrie commented May 29, 2014

Why do numeric types wrap on overflow? See also http://blog.regehr.org/archives/1154

(not so relevant anymore. -nmatsakis)

@bstrie
Copy link
Contributor Author

bstrie commented May 30, 2014

Why must mod follow use?

(not so relevant anymore. -nmatsakis)

@steveklabnik
Copy link
Member

Now that #14370 has been closed, can we close this?

@alexcrichton
Copy link
Member

This thread still has many questions which aren't present in the FAQ, so we may in theory want to add all of them to the FAQ before closing this.

@brson
Copy link
Contributor

brson commented Jun 24, 2014

Agree. We've collected a lot of info here that I don't want to lose.

@pnkfelix
Copy link
Member

"Why does let _ = ... behave differently from let _x = ..." : #15151 , #10488 (comment)

@alexchandel
Copy link

"Why is there no float type?" or "Why is there int and uint but not float?"

@theemathas
Copy link
Contributor

Why do we need Copy if we already have Clone?

@theemathas
Copy link
Contributor

Why is moving function arguments the default, not borrowing or copying/cloning?

@alexchandel
Copy link

"Why is i32 the default?" and "Why aren't isize and usize named after C's intptr_t and uintptr_t?"

@steveklabnik
Copy link
Member

I'm pulling a massive triage effort to get us ready for 1.0. As part of this, I'm moving stuff that's wishlist-like to the RFCs repo, as that's where major new things should get discussed/prioritized.

This issue has been moved to the RFCs repo: rust-lang/rfcs#615

@pnkfelix
Copy link
Member

Oh no! It was really nice that this list was all in one place!

@pnkfelix
Copy link
Member

2015Feb20 10:23 <eddyb> wrote:

pnkfelix: do we have a FAQ-style answer for "why disallow destructuring types that impl Drop"?

@steveklabnik steveklabnik reopened this Feb 20, 2015
@steveklabnik
Copy link
Member

I'm pulling a massive triage effort to get us ready for 1.0. As part of this, I'm moving stuff that's wishlist-like to the RFCs repo, as that's where major new things should get discussed/prioritized.

This issue has been moved to the RFCs repo: rust-lang/rfcs#891

Update from pnkfelix: No, that attempted move failed. See rust-lang/rfcs#615

@alexchandel
Copy link

I guess closing all your issues is a nice way to pretend they're not issues. Adding an FAQ shouldn't need to go through the RFC process.

@steveklabnik
Copy link
Member

@alexchandel the RFC repo issues are not just for things going through the process. It's also full of suggestions for things like community libraries that could be done. The result of this won't need to go through the RFC process, it's just that I don't plan on writing this any time soon.

@pnkfelix
Copy link
Member

Note also that there are prototype FAQ documents already in src/doc:

(Nonetheless, these tickets remain worthwhile catch-all lists of questions that may not yet have answers on any of those three documents. I'm still not thrilled with the pseudo-migration to the RFC repo.)

@steveklabnik
Copy link
Member

steveklabnik commented Feb 23, 2015 via email

@pnkfelix
Copy link
Member

Why can't I do destructuring-bind in a trait default method?

For an example, see this playpen

See discussion from 2013-09-10, though it seems like the "decision" there was never implemented (and likely never will at this point?)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests