Comments (12)
Ideally, to_s would return the current representation and inspect would return yours; however, I don't know how many people rely on the return values being what they are, and it's probably not worth a major version bump.
from ast.
Data point: I do not rely on AST::Node#to_s
or #inspect
format in my projects.
from ast.
What about @bbatsov?
from ast.
my idea was that you only get it when you want it.
One could decouple it from including the Sexp and make different module if there are concerns.
from ast.
It is definitely a past design failure in ast.
from ast.
I'm on the road right now. Will be back home tomorrow and I'll take a look
then.
On Tuesday, September 15, 2015, whitequark [email protected] wrote:
It is definitely a past design failure in ast.
—
Reply to this email directly or view it on GitHub
#6 (comment).
Best Regards,
Bozhidar Batsov
from ast.
After having used this a bit more, i actually reverted to the multiline version. (wasn't before)
It now outputs exactly what is written in the module comment.
Even in ruby code, that can still be pasted, as the comma at the end continues the expression.
(though i personally changed to text files, less clutter)
https://github.com/dancinglightning/ast/commit/846eb00aeb6d227ffbae7a3f5c3b286f60d11667
from ast.
Ideally, to_s would return the current representation and inspect would return yours; however, I don't know how many people rely on the return values being what they are, and it's probably not worth a major version bump.
I'm not using this is as well, so I think making this change is unlikely to affect many (any) users.
from ast.
OK. I will accept a PR implementing this as per #6 (comment).
from ast.
ok, do you want it in the sexp module (as my code is now), or should i change the node.to_sexp to output ruby code ?
from ast.
No, no modules. Just inspect
(outputting the code) and to_s
(aliased to to_sexp
).
from ast.
i guess this is clear
from ast.
Related Issues (11)
- #inspect should return valid Ruby code HOT 3
- each and first HOT 7
- How to get the parent of a node? HOT 2
- Documentation: missing a ` HOT 2
- It would be nice if inspect could include property keys or some subset of properties.
- Actualize changelog
- Local properties are not propagated HOT 2
- How do you handle node references? HOT 11
- Adding/ removing child nodes in existing AST HOT 6
- process context HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ast.