I wanted to follow up on Wednesday's message regarding self-calls.
TL;DR: problem solved, and you can now write self-calls that take
arguments.

Longer version: Graydon suggested a change to the way we parse
self-calls that really simplifies middle-end processing.  In
particular, instead of distinguishing an expr_call_self node, we use
the usual expr_call node for self-calls, and then a new
expr_self_method node as the expr_call's subexpression.  Doing this
allows more code reuse and makes typechecking tractable; also, this
new AST representation for self-calls now fits together nicely with
how we were already handling self-calls in trans.rs.  So I barely had
to change trans.rs at all after making the necessary front-end and
typechecker changes.

So, now rustc can compile code that looks like: 
https://github.com/graydon/rust/blob/master/src/test/run-pass/obj-self-3.rs

Note that we still don't have first-class support for 'self'.  That
is, we don't have a 'self' type; we can't take 'self' as an argument
nor can we return it from a function.  But I'm hoping that just
self-calls alone make objects more useful for the time being!

Before tackling self-types, I'm going to change gears for a bit and
work on attempting to model the operational semantics of Rust in PLT
Redex.  In a few days I should have a better idea of whether the Redex
idea is worth continuing to pursue.  In the meantime, feel free to
pound on 'self' and assign me bugs.  :)

Lindsey
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to