Re: Phix syntax
- Posted by petelomax Dec 18, 2020
- 1033 views
That's not an entirely mad idea.
As you say, if name is public, then w.name operates as normal and doesn't invoke any "magic", and I wouldn't change that.
At the moment, if name is private, it is a runtime error, which is too late to do anything about it.
If I first changed it, as I probably should, to a compile-time error, that could open up further possibilities.
It could, just before issuing such an error, check for (public) get_name/set_name methods and invoke those instead,
or to be pedantic about it, emit the appropriate code to invoke them/pretend they'd been written that way.
I don't think it would need any specific syntax, accessing a private xyz would make it look, depending on context,
for either a single parameter (and public) set_xyz procedure, or a parameter-less get_xyz function.
Note that w["name"] style access wouldn't change.