← Home ← Back to /g/

Thread 105566497

31 posts 10 images /g/
Anonymous No.105566497 [Report] >>105566957 >>105566967 >>105570229 >>105570703 >>105571144 >>105571927 >>105573205
Why Won't Rust Give Us APIs To Access AST
Is Rust making a mistake by not giving us working APIs to access the AST?
Anonymous No.105566518 [Report]
learn some proper language
Anonymous No.105566957 [Report]
>>105566497 (OP)
because rare is the language that wants to formalize its ast. woo woo implementation details
Anonymous No.105566967 [Report] >>105567845 >>105570229 >>105572044
>>105566497 (OP)
Use case?
Anonymous No.105567845 [Report] >>105567918 >>105571109
>>105566967
Anonymous No.105567886 [Report]
Just write your own parser, bro.
Anonymous No.105567918 [Report] >>105568263
>>105567845
what even is this from. why should I care?
Anonymous No.105568263 [Report]
>>105567918
you shouldn't, you are a nocoder
Anonymous No.105570229 [Report]
>>105566967
>>105566497 (OP)
it will most likely happen at some point.
in order to make a rust compiler, you have to use the exact same tokens as rustc for proc macros support.

proper rust implementation will likely require to follow rustc's ast. the issue with standardizing an ast is that it's harded to add new language features since you need to update the ast definition. maybe it will be like java where each compiler has it's own ast, but libraries exist to bridge the gaps between different compilers
Anonymous No.105570384 [Report]
AST macros are an anti-feature
more trouble than they're worth
Anonymous No.105570703 [Report]
>>105566497 (OP)
because cult
Anonymous No.105571109 [Report]
>>105567845
Lisp can already do all this lol.
Anonymous No.105571133 [Report] >>105571872 >>105571965 >>105572163 >>105572230 >>105572303 >>105572376 >>105572440 >>105572500 >>105572944
You cannot do this in Rust, because Rust is a bad language.
However, you can do that in Hare, because Hare is a good language.
Anonymous No.105571144 [Report]
>>105566497 (OP)
I don't think it will ever happen. Rust is understandably afraid of setting in stone all its internal representations by exposing them as a stable API.
We have to wait several decades until programming languages are "solved" and people aren't so afraid of being left behind anymore.
Anonymous No.105571872 [Report]
>>105571133
pick up the phone, Salad
Anonymous No.105571927 [Report]
>>105566497 (OP)
https://docs.rs/syn/latest/syn/
Anonymous No.105571965 [Report]
>>105571133
any good threads on >>>/c/ drew?
Anonymous No.105572044 [Report] >>105572106
>>105566967
source generators, analyzers. for example C# provides a semantic model of code. and this is much more powerful than AST. this is like reflection, but for compiled source code.
Anonymous No.105572106 [Report] >>105572192
>>105572044
But you can already use procedural macros for this.
Anonymous No.105572163 [Report]
>>105571133
HOLY BASED
Rustfags malding
Anonymous No.105572192 [Report] >>105572247 >>105572338
>>105572106
procedural macros are limited, because they only have access to AST, not semantic model

also, in C# you can provide analyzers as a package (https://github.com/Cybermaxs/awesome-analyzers) which can generate code warnings, errors, provide code refactorings (for example, detect a certain code pattern and rewrite it into more optimized form)
Anonymous No.105572230 [Report]
>>105571133
/g/ is not ready for this TRVKE
Anonymous No.105572247 [Report]
>>105572192
an ast is by definition a "semantic model of code"
Anonymous No.105572303 [Report]
>>105571133
TSMT
Anonymous No.105572338 [Report]
>>105572192
>procedural macros are limited, because they only have access to AST
But OP claims they do not. That's what I am talking about.
Anonymous No.105572376 [Report]
>>105571133
This.
Anonymous No.105572440 [Report]
>>105571133
Rustrannies will never reach this level of basedness. Let's be real here, they will never be real womens
Anonymous No.105572500 [Report] >>105572608
>>105571133
QRD? Where can I learn Hare? Where can I find out more about it? I am interested.
I hope it is not one of those languages where the creator is Ukraine supporter and makes sure everyone knows it.
Anonymous No.105572608 [Report]
>>105572500
You are actively practicing the identity politics you pretend to hate. I have a contract with each of at least eight search giants.
Anonymous No.105572944 [Report]
>>105571133
/thread
Anonymous No.105573205 [Report]
>>105566497 (OP)
Because it's a meme/toy language. First we need a spec, then we can talk.