Dechenjm / crack-language

Automatically exported from code.google.com/p/crack-language
Other
0 stars 0 forks source link

Field accessors should be operators #50

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
As it stands, field (or instance variable) access gets special treatment from 
the compiler: when we see a field access or assignment of the form "x.a" or 
"x.a = b" a model object expression gets generate for the reference or the 
assignment.

These should instead be represented as a FuncCall object derived from the 
function "oper get <fieldname>" and "oper set <fieldname>".  Switching to this 
form will allow us to overload field accesses and also allow us to better 
accommodate extensions (see Issue 49) by generating offsetting code to access 
fields in native structures.

There should be no runtime cost associated with this for normal fields: in the 
case of instance variables, these functions can be defined to do the same field 
access code generation that they do now.

Original issue reported on code.google.com by mind...@gmail.com on 20 Oct 2010 at 12:07

GoogleCodeExporter commented 9 years ago
Would this be like the getter and setter properties in python, where a set of 
functions can be associated with the access and modification of an object's 
instance variables?

Original comment by Clay.Swe...@gmail.com on 21 Dec 2012 at 1:54

GoogleCodeExporter commented 9 years ago
Yes, pretty much.

Original comment by mind...@gmail.com on 21 Dec 2012 at 2:35