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

Implement method call syntax #31

Closed
masak opened this issue Oct 10, 2015 · 2 comments
Closed

Implement method call syntax #31

masak opened this issue Oct 10, 2015 · 2 comments

Comments

@masak
Copy link
Owner

masak commented Oct 10, 2015

#25 talks about method call syntax (which is actually just a property lookup plus a function call, much like Python and JavaScript).

There's nothing preventing us from implementing those ahead of time, without having object literals. If we're going that path anyway, then we could do the property lookup/method call as a standalone thing.

Why would that matter? Because the setting currently contains a bunch of accessors/destructors for the Qtree nodes, that would be much more intuitive as methods on the Qtree nodes themselves:

value params stmts expr lhs rhs pos args ident assign block

Thus, you could do this:

my q = quasi { say("Three plus four is " ~ (3 + 4)) };
say(q.stmtlist()[0].expr().arglist()[0].rhs().lhs().value()); # 3

Instead of (as you currently have to):

say(value(lhs(rhs(arglist(expr(stmtlist(q)[0]))[0])))); # 3

This would have the further advantage of uncluttering the setting a bit more.

@masak
Copy link
Owner Author

masak commented Oct 20, 2015

Implemented in 410db3a.

@masak masak closed this as completed Oct 20, 2015
@masak
Copy link
Owner Author

masak commented Oct 30, 2015

Coming back to this issue, I was surprised that I felt that all the Q properties ought to be methods. It complicates both the 007 syntax and the implementation. In fact, they're just immutable value properties. I think this was a kind of thinko, cargo-culting from subs to methods.

f244919 fixes this.

The example above now turns into

my q = quasi { say("Three plus four is " ~ (3 + 4)) };
say(q.stmtlist[0].expr.arglist[0].rhs.lhs.value); # 3

And it works under that new commit.

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

1 participant