The first stage would be to unify the struct and type keywords.
Current syntax
struct Name {
first: ~str,
last: ~str
}
struct Point(int, int);| fn main() { | |
| let stuff = ~[~"one", ~"two", ~"three"]; | |
| stuff | |
| .map(|s| str::append(~"lol", *s)) | |
| .map(|s| io::println(*s)); | |
| } |
| use to_str::ToStr; | |
| macro_rules! map_cast( | |
| (~[$($elems:expr),+] -> $T:ty) => (~[$($elems as $T),+]); | |
| (@[$($elems:expr),+] -> $T:ty) => (@[$($elems as $T),+]); | |
| ($arr:expr -> $T:ty) => ($arr.map(|a| *a as $T)); | |
| ) | |
| fn main() { | |
| let arr1 = map_cast!(~[1, 2.5] -> ToStr); |
| RUSTC ?= rustc | |
| #LOG_FLAGS ?= RUST_LOG=rustc::metadata::creader | |
| all: glhex | |
| run: all | |
| ./glhex | |
| glhex: main.rs *.rs |
The first stage would be to unify the struct and type keywords.
Current syntax
struct Name {
first: ~str,
last: ~str
}
struct Point(int, int);| use std::{os,str}; | |
| fn main() { | |
| let args = os::args(); | |
| match args.tail() { | |
| [~"-n",..strs] => print(str::connect(strs, " ")), | |
| strs => println(str::connect(strs, " ")), | |
| } | |
| } |
| fn new_foo(a: &Path) -> Result<~Foo, ~str> { | |
| read_whole_file(a).chain(|b| frob(b)) | |
| .chain(|b| baz(b)) | |
| .map_move(|b| ~Foo { bar: b }) | |
| } |
| extern crate serialize; | |
| use serialize::json; | |
| fn get_string<'a>(data: &'a json::Json, key: &~str) -> Option<&'a str> { | |
| match *data { | |
| json::Object(ref map) => { | |
| match map.find(key) { | |
| Some(&json::String(ref s)) => { | |
| Some(s.as_slice()) |
| use std::iter::Iterator; | |
| fn map<T, U, I: Iterator<T>>(fun: |T| -> U, mut iter: I) -> Vec<U> { | |
| let mut acc = vec![]; | |
| for elt in iter { | |
| acc.push(fun(elt)); | |
| } | |
| acc | |
| } |
| rustc src/lib.rs -o idris/idrisfs.o --crate-type=lib --emit=obj | |
| Undefined symbols for architecture x86_64: | |
| "___morestack", referenced from: | |
| _sizeof_int in idrisfs.o | |
| sizeof_int::__rust_abi in idrisfs.o | |
| mem::size_of::h1f2d9faff57bec09oaa::v0.0 in idrisfs.o | |
| ld: symbol(s) not found for architecture x86_64 | |
| clang: error: linker command failed with exit code 1 (use -v to see invocation) | |
| FAILURE: gcc -O2 -fwrapv -fno-strict-overflow -I. ./idrisfs.o -x c /var/folders/_t/g72k9vzd30b5svvyd1nxpwp40000gn/T/idris5178 -L/Users/sven/Library/Haskell/ghc-7.6.3/lib/idris-0.9.12/share/rts -lidris_rts -lgmp -lpthread -I/Users/sven/Library/Haskell/ghc-7.6.3/lib/idris-0.9.12/share/rts -I. -I/Users/sven/Library/Haskell/ghc-7.6.3/lib/idris-0.9.12/share/prelude -I/Users/sven/Library/Haskell/ghc-7.6.3/lib/idris-0.9.12/share/base -o /var/folders/_t/g72k9vzd30b5svvyd1nxpwp40000gn/T/idris5176 |
| // user application | |
| loop { | |
| window.poll_events(); | |
| } | |
| // mac/glutin | |
| fn poll_events(&self) { | |
| nsapp_waitevent(); |