5 ms·
Makes me wonder if there could be a lisp that transpiles to rust
by leoh 4y ago
Makes me wonder if there could be a lisp that transpiles to rust
- tmtvl 4y agoThere could be, but it'd be kinda painful because you've got a lot of Rust code that's very Java-esque. return args().skip(1).next().unwrap().length(); EDIT: a Lisp transpiling to Rust would have to figure out for every function call whether it's a standard function call or a method call.
- kaashif 4y agoAbout method chains and Lisp: in Clojure you can write code very similar to that using threading macros: (-> (args) (skip 1) (next) (unwrap) (length)) I really do think that for long "Java-esque" chains like this, Clojure has the right idea, I think it's very readable. This isn't really related to the Lisp to Rust transpiling thing though.
- tmtvl 4y agoThere is an SRFI for a chain macro which works like that, but the problem is that we'd need to figure out for each call whether we need to transpile it to a function or a method call. And I agree with you that that S-expression notation is very readable, at least for us who are used to putting the parentheses in the correct spot.
- xigoi 4y ago> a Lisp transpiling to Rust would have to figure out for every function call whether it's a standard function call or a method call. You could use slightly different syntax, such as (foo x) versus (.foo x).
- andrewflnr 4y agoThat's definitely not the hard part of targeting Rust. I don't really understand why people keep thinking it's a good idea, Trying to generate borrow-checker compliant code sounds like a nightmare.
- googlryas 4y agoOf course there can be. Show me an AST, and I will show you a lisp!
- leoh 4y agoWell yes, of course. The question is if one can create a reasonably ergonomic lisp that transpiles to Rust. I'd tentatively imagine the borrow checker could make this difficult.