4 ms·
Does anyone have an example? I don't have any of the toolchain, and it seems like a lot to do to see a compiled example.
by StavrosK 13y ago
Does anyone have an example? I don't have any of the toolchain, and it seems like a lot to do to see a compiled example.
- steveklabnik 13y agoWell, you'd never see the compiled example. You'd compile the example in the README, and it'd give you a binary. It's a macro, not like CoffeeScript. That said, you could view the expanded output if you were curious. You'd pass `--pretty expanded` to `rustc`. The pretty printer isn't great yet, though. I would run it for you and give you a gist, but I'm not at a computer with the toolchain either.
- ben0x539 13y agoThe example in the readme: http://ix.io/cdR http://ix.io/cdR Emitted llvm ir doesn't look much more compact either: http://ix.io/cdS http://ix.io/cdS Clearly there is still plenty of room for optimizing brainfuck compilers!
- eridius 13y agoEh, compile with -O and let LLVM optimize it.
- dbaupp 13y agoYeah, the implementation is literally just a token-by-token transliteration into Rust, just hoping that LLVM makes it go fast (and it does go pretty fast, e.g. it's faster than bff4[1], which Esolangs[2] touts as the fastest interpreter). The Rust output & optimised IR clearly show there's room for improvement, though. [1]: http://mazonka.com/brainf/ http://mazonka.com/brainf/ [2]: http://esolangs.org/wiki/Brainfuck_implementations#Optimizing_implementations http://esolangs.org/wiki/Brainfuck_implementations#Optimizin...
- StavrosK 13y agoOh, thanks, I thought it compiled to rust code, I didn't realize it compiled to a binary.
- steveklabnik 13y agoMacros expand to Rust code, but not as a separate file or anything. It's a form of meta programming.