Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Towards Nemerle 2 - Base Language + Multiple Layers of Macro Define features #13330

Open
sirinath opened this issue Jan 16, 2017 · 4 comments
Open

Comments

@sirinath
Copy link

sirinath commented Jan 16, 2017

With regarding implementing N2 the following approach will make life easy.

There should be a minimal core with macros with macros implementing most of the language features.

The base language features which might be needed are:

  • Typed macro with term rewriting capabilities
  • Heterogeneous Data Structures (Lists, Maps, Multimaps, Sets, Ordered Sets, Multisets, and Graphs) - many of these structure are special cases of H. List and H. Map, so this can be implemented with macros, proofs and capabilities
  • Pattern matching
  • Strong typing system (Dependent types, effects / tags / annotations, GADT)
  • Proofs

Macros:

  • This is what the language will be defined on

Heterogeneous Data Structures

  • Classes, modules and packages are H. Maps
  • Functions take H. Lists as parameters
  • Code block is a H. List of closures
  • H. Tree of Symbols can model nominative typing

Proofs

  • this can be used for type inference, type checking and optimisation
  • Object capabilities based on type annotations / type extension / type tags with macro processing and proof system
    • Object capabilities macro annotation processing can implement access modifiers

Also what might not be not needed in base or level 0 language:

  • Strictness, laziness - evaluation is undefined (not eager or lazy) - this will give more room for optimisation
  • member functions - functions are closures in the H. Map
  • functions - already have closures
  • Loops - recursive closures with pattern matching - this can be defined with macros
  • Branching - you have pattern matching - this can be defined in a macro

Some inspiration for this:

But with syntax which is more readable (http://readable.sourceforge.net/) than Lisp variants above. Inspiration does not mean all features from all language but minimal essential features for the core with macros defining each layer.

Also it is not the intention of the general user or programmer to use Nemerle Base / Level 0 abstractions.

@sirinath sirinath changed the title Towards Nemerle 2 - Base Language Towards Nemerle 2 - Base Language + Multiple Layers of Macro Define features Jan 16, 2017
@pr-yemibedu
Copy link

pr-yemibedu commented Jan 18, 2017

For evalution, it could be an explicit scope used to determine lazy or strictness. that can be tucked away with a macro that always simplier typing to specify such. [ strict scope ] and { lazy scope } which can be used in a (top default scope). you can then write ({display [and x y ] {or x y}}) as needed to dictate intent.

https://web.cs.wpi.edu/~jshutt/kernel.html

http://www.dalnefre.com/wp/2011/12/semantic-extensibility-with-vau/

http://mainisusuallyafunction.blogspot.com/2012/04/scheme-without-special-forms.html

@sirinath
Copy link
Author

sirinath commented Jan 19, 2017

Environment

Environments map Symbols to values. They are first-class semantic objects, yet their structure is opaque. They cannot be decomposed by operatives. This is one of the key principles underlying the safety of extensibility in Kernel. Operatives can manipulate syntax, but cannot violate the encapsulation of semantic values. This gives us the freedom to implement environments using more efficient native mechanisms of Humus, including functional representation of bindings and lazy initialization of environment actors.

Source: http://www.dalnefre.com/wp/2011/12/semantic-extensibility-with-vau/

I think the environment should not just be mapping symbol to value but should have a pair of symbol and type to value.

@pr-yemibedu
Copy link

pr-yemibedu commented Jan 19, 2017

the environment does not bind to any value. the environment is used to evaluate an expression.
the expression would always do a lookup for the type that is valid in an environment.
the value you mention is just the local storage use at a call site when an evaluation actually occurs.
so {x + x} could be given an environment where x has an int type or float type.
it can also have an environment where the expression only evaluates to first occurrence of the x and caches it for later lookups.

@dumblob
Copy link

dumblob commented Apr 9, 2021

@sirinath those are really great ideas! Also thanks for the links - they're very inspiring. I'll add one more recent (2019) article about "macro language from the bottom to the top" - it's a "rant" about Racket still not fully achieving this goal despite a lot of success in that regard (IMHO the closest existing language to the goals outlined by you in this discussion thread).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants