On Sep 17, 2014, at 7:04 AM, Daneel Yaitskov <rtfm.rtfm.r...@gmail.com> wrote:

> Hi,
> 
> 
> Does Rust macro have flow control based on a variable value?
> 
> I didn't find such info here  http://doc.rust-lang.org/guide-macros.html.
> 
> I'd like to get a macro expading a for loop.
> 
> doTimes(3, println!("DDDD"))
> =>
> println!("DDDD")
> println!("DDDD")
> println!("DDDD”)

Perhaps I’m misunderstanding you, but in general that’s impossible. 
Specifically, variable varues aren’t known at runtime. So, for instance, if you 
wrote

doTimes(x, println!(“DDDD”))

… there’s no way (in general) to know the value of ‘x’ until the program is run.

Is there some reason you can’t just use a function call, here?

John Clements

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

Reply via email to