I’ve been toying with the idea of generalized “pseudo-object syntax”, which would essentially be a form of syntax sugar.
It would allow passing the first parameter of a function call with the method syntax, f.i.
i.IntToStr(); i.Inc( 2 );
would be understood as being just a syntaxical variation of
IntToStr( i ); Inc(i, 2);
Essentially, every class-less function/procedure could become a generalized class helper, that could operate on just about any type. Additionnally (or declaratively) you could also use a variation of the declaration f.i.
function Integer.IntToString() : String
could be equivalent to
function IntToString( Self : Integer ) : String
Of course there are some visibility issues to decided on, f.i. if I have a myClass.ToString method, would it take precedence over a ToString(myClass) function (I would say it should)? and whether such an extensibility would be implicit or declarative?
Do you know any language that implements such an approach?