A Quick Look at the Rust Programming Language
bluishcoder.co.nz
bluishcoder.co.nz
[1] https://github.com/graydon/rust/wiki/Project-FAQ
[2] http://groups.google.com/group/golang-dev/browse_thread/thre...
One of the contributed examples is some kernel development [2].
[1] http://www.ats-lang.org/ [2] http://ats-lang.svn.sourceforge.net/viewvc/ats-lang/trunk/co...
Sadly they dropped the Lisp syntax.
http://hasp.cs.pdx.edu/habit-report-Nov2010.pdf (sorry, no non-PDF documentation)
There was an LtU thread as well:
LtU has a thread on Rust: http://lambda-the-ultimate.org/node/4009
Can sombody please explain how "pure-functional" (where I think that "pure" means "without side effects") mixes with "imperative"?
Or do I misunderstand the "pure" part?
Eg, functional code could looks something like this:
foo a b = if a < b then quux (map bar a) else b
while a pure imperative function could look something like this: int foo (string a, int b) { // since a is passed by value, mutating it below will not modify the original
if (a < b) {
for (int idx=0; idx<a.length; ++idx) {
a[idx] = bar(a[idx]);
}
return quux(a);
} else {
return b;
}
}
Obviously this example is contrived and dumb, but both do the same thing and, besides the syntax difference, the first is written in a functional style, the second in an imperative style, but both are still pure (as long as bar and quux are also pure).So you can mix functional and imperative without making functions impure.
Pure functions that return a boolean value can be used in the typestate system (ie. typestate calls must not have side effects). 'pure' functions cannot call 'impure' functions, etc.
I'm guessing that's what the quoted sentence refers too.
Keep this in mind (from the wiki article):
One problem with the name Resource Acquisition Is Initialization
is that it is inaccurate: it's not always about resources, and
it is nothing to do with initialization -- what makes the idiom
tick is finalization.In Rust, the semicolon is the expression sequencing operator (like in ML), not a statement terminator. "a;b" means "evaluate a, throw away the result, and return the result of evaluating b". So the semicolon is more than just boilerplate.
I guess we could do some sort of automatic semicolon insertion like JavaScript, but I'm not sure that the benefits outweigh the complexity.
It's obviously very useful to use ';' in the scenario you mention, I think a good comparison is F# which doesn't force semicolons but does permit usage like that. I guess, e.g.:-
foo bar baz
implies foo |> ignore; bar |> ignore; baz
Oh, and just to make it very clear, I am talking about something really rather petty, I do not mean to do down rust in any serious way - I'm a wannabe-language designer myself, so major respect to you guys :)
http://code.google.com/p/go/source/browse/src/cmd/gc/go.y
/*
* Go language grammar.
*
* The Go semicolon rules are:
*
* 1. all statements and declarations are terminated by semicolons.
* 2. semicolons can be omitted before a closing ) or }.
* 3. semicolons are inserted by the lexer before a newline
* following a specific list of tokens.
*
* Rules #1 and #2 are accomplished by writing the lists as
* semicolon-separated lists with an optional trailing semicolon.
* Rule #3 is implemented in yylex.
*/
But obviously this is very language-specific and given the case discussed above likely not to work in quite the same way.1. Semicolons terminate statements.
Look at the rules for Go semicolon usage[1] or Javascript semicolon usage[2] or Python newline usage[3]. They're not simple. Entire essays can be and have been written describing the complexity introduced by saving programmers that single keystroke.
Maybe I'm crazy, but I want my tools to be simple. I would much rather type a thousand extra semicolons than spend extra hours internalizing the statement termination rules of the languages I use.
[1] http://groups.google.com/group/golang-nuts/browse_thread/thr...
rt: d884:main:main: upcall fail '.t0 < 3u', ts2.rs:5
Yikes!