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

Add a meta statement #40

Open
evhub opened this issue Dec 9, 2015 · 3 comments
Open

Add a meta statement #40

evhub opened this issue Dec 9, 2015 · 3 comments

Comments

@evhub
Copy link
Owner

evhub commented Dec 9, 2015

Syntax should be

meta <lhs>:
    <body>
    <return rhs>

which should have its <body> run and then compiled to

parse(lhs + " = " + ascii(rhs))
@evhub
Copy link
Owner Author

evhub commented Dec 9, 2015

This should allow support for both compile-time optimization like so

meta expensive_func_memo:
    return {arg: arg |> expensive_func for arg in common_args_to_expensive_func}

and embedded metaprogramming like so

meta val:
    data obj:
        def __repr__(self):
            return """<code>"""
    return obj()

@evhub
Copy link
Owner Author

evhub commented Dec 9, 2015

Also added should be a simple in-line meta assignment like

meta concatenated_string = (
    "line 1"
    "line 2"
    "line 3"
    )

or from the above example

meta expensive_func_memo = {arg: arg |> expensive_func for arg in common_args_to_expensive_func}

@evhub evhub closed this as completed Dec 10, 2015
@evhub
Copy link
Owner Author

evhub commented Jun 20, 2017

Potentially just add a meta expression that gets evaluated at compile time and the result inlined. The code

meta(<expr>)

could inline the result of evaluating

() |*> (def () -> <expr>) |> repr

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

No branches or pull requests

1 participant