Comments (3)
As time passes, I find myself leaning more and more strongly towards "they should both exist, and be separate".
I have two new pieces of evidence, for some very loose definition of "evidence":
-
Swift macros. I'd need a lot more time and headspace to be able to state clearly what I think is great about them, but... one thing they do well is to (it seems to me) interact with class declarations and their members. While this could still be phrased directly in terms of ASTs (and maybe it is?) the amazing difference compared to Lisp- and Scheme-like macros is that it doesn't feel like we're working on just syntax anymore; we're working with full awareness of the declaration structure of, say, a class declaration.
-
Herb Sutter's proposed C++ metaclasses (later renamed to metafunctions, if I understood it right in that keynote). The API here seems like it's in dialogue with a set of "mirror"-like objects, and something like
t.add_virtual_destructor();
seems to me to be quite high-level and no longer just AST.
from alma.
I think it's impossible to have a discussion about this without talking about phases and binding times.
What can you see, when? Do macros and classes "appear" into existence at the same time?
If macros were only concerned with syntax and parsing, they'd be considered before any kind of analysis, and classes would just be a node amongst others.
If you consider that macros need to be able to interact with the MOP, you need to interleave both, but how isn't always obvious.
If you have a macro call inside of a class, should it be able to retrieve said class? Either by name or by "surrounding context"? In that case, what should the class look like? A stub, hole-y node, waiting to be completed? (that actually sounds like a quote if you get very very very creative, because it has a hole and because it shouldn't appear in the final AST).
On the other hand, if you collect macros inside of the class body and delay them (that is, after the initial declaration but before "sealing" or - to reuse Raku vocab - "composing" the class) to run them all at once, you might be able to provide a more sensible view of the class.
Early-binding languages and mop<=>macros interactions is not something that's well-researched, I think, and it kind of shows.
from alma.
I think it's impossible to have a discussion about this without talking about phases and binding times.
What can you see, when? Do macros and classes "appear" into existence at the same time?
I think this is the right way to approach the whole thing, yes.
I hereby declare my intention to review a few languages from the above perspective — what can you see, when? — in order to shake out some understanding from that about what modern languages actually do.
My candidate languages will be: Java, Perl 5, Raku, Python, and CLOS. The focus will be on the object metamodel, and at which exact point during the compilation process it becomes accessible.
from alma.
Related Issues (20)
- Add Records and Tuples (as a syntax extension) like in the TC39 proposal
- Consider code coverage (as a code generation technique) HOT 9
- Consider having a ? operator on calls (like Rust) for error propagation HOT 3
- React in some way to Flatt's "Binding as a set of scopes" work in Racket HOT 6
- Suggestion: add alma to an online evaluator HOT 1
- Get off Travis HOT 1
- Move get, set, and has to be on Dict instead of on dictionary instances
- Alma's (and Raku's) quasi scoping is significantly different from Scheme's/Lisp's HOT 16
- Add a test for nested unquotes HOT 1
- Reasons for modules HOT 72
- Add an `under` macro for bidirectional transformation HOT 2
- The quasi in the example name.alma doesn't need to take a closure
- Handle (ignore) the BOM
- Fix mis-implemented test
- A unification of access paths HOT 2
- Handling of MAIN over-catches X::ParameterMismatch exceptions
- Add a test for unquotes _not_ being first-class syntax
- Add a closure test to the test suite
- Will no longer be updated to the Raku ecosystem
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 alma.