[Grace-core] Name resolution in Grace

Andrew P Black andrew.p.black at gmail.com
Tue Jul 9 13:58:41 PDT 2013


I think that Lex is right to point out that "we have reached a
point where if you write foo(), you aren't so much eliding obvious
boilerplate as asking for additional dynamism in the dispatch
algorithm."

The world would indeed me much simpler to explain if we always made the recover explicit.  So why don't we?

Two reasons.  We made outer implicit so that we can get "methods" from a dialect without having to write outer.if()then()else() and so on.  We made self implicit so that we could write "functional" code like

	method factorial(n) { 
		if (n ≤ 1) then {1} else { factorial(n-1)*n }  
        }

	print( factorial 9 )

at the top level, and introduce and use functions without having first to explain objects.

I wonder if it's time to revisit those decisions?  Suppose that  Grace actually had (lexically-bound) procedures as well as (dynamically-bound) methods, and all methods had an explicit receiver?   Yes, that's one more concept.  But don' the name resolution rules get dramatically simpler?   And now we get "private methods" (aka procedures) too.

	Andrew


More information about the Grace-core mailing list